globalize icon indicating copy to clipboard operation
globalize copied to clipboard

Requires for the client to split long messages at a space character and remove the space chacter?

Open Setogit opened this issue 10 years ago • 3 comments

globalize seems to support a message by splitting to multiple messages. That seems useful (or necessary?) for long messages.

In case of split, does globalize require the client to split the message at a space character and remove the space character? Why doesn't it let the client simply split at any point?

Have not tried it. Just a question came up in mind while reading the source. Pls ignore if i missed something.

https://github.com/jquery/globalize/blob/master/src/message.js#L81

    // If message is an Array, concatenate it.
    if ( Array.isArray( message ) ) {
        message = message.join( " " );
    }

Setogit avatar Mar 25 '16 19:03 Setogit

Good question.

The space addition was intended to prevent merging words that were visually separated by the new line, for example in the below the space prevents merging do with eiusmod.

Globalize.loadMessages({
  en: {
    long_message: [
      "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do",
      "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad",
      "minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip",
      "ex ea commodo consequat. Duis aute irure dolor in reprehenderit in",
      "voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur",
      "sint occaecat cupidatat non proident, sunt in culpa qui officia",
      "deserunt mollit anim id est laborum"
    ]
  }
});

Having said that, the space addition might be an incorrect approach and could incorrectly change sentences of certain locales. For example, I believe it would make a Japanese sentence wrong. AFAIK they don't use space as word boundaries.

In long message-format messages like this one, the space addition might do no harm, but also no good.

rxaviers avatar Mar 26 '16 01:03 rxaviers

I think the spaces should be in the long-message strings (a newline character if that's what needed, a space character, or nothing).

sompylasar avatar Mar 26 '16 09:03 sompylasar

Yeah, @rxaviers is right on "space not used as word separator in Japanese." The code implies that the state of mind of the designer/writer of the code was in Latin language centric.

Setogit avatar Apr 07 '16 15:04 Setogit