Changes between Version 14 and Version 15 of Internationalization


Ignore:
Timestamp:
Apr 19, 2014, 12:06:06 PM (10 years ago)
Author:
sanderd17
Comment:

Improve info about translateObjectKeys

Legend:

Unmodified
Added
Removed
Modified
  • Internationalization

    v14 v15  
    180180translateObjectKeys(settings.ais, ["name", "description"]);
    181181}}}
     182
     183Note that the keys don't have to be top-level keys (the method searches the entire object depth first), and that the object may not have circular references (which is usual when it's only about data objects).
     184
     185The keys you provide should either be strings in the object that can be translated, or a special object, like shown in the next example.
     186{{{
     187{
     188  translatedString1: "my first message",
     189  unTranslatedString1: "some string",
     190  ignoredObject: {
     191    translatedString2: "my second message",
     192    unTranslatedString2: "some string"
     193  },
     194  translatedObject1: {
     195    message: "my third message",
     196    context: "message context",
     197  },
     198  translatedObject2: {
     199    list: ["list", "of", "strings"],
     200    context: "message context",
     201}
     202}}}
     203
     204It will translate "translatedObject1" using a certain context, and every string in the list of "translatedObject2" also with the same context, after which the list will also be joined with a localised connector (", " in English). So the result could be
     205
     206{{{
     207{
     208  translatedString1: "mijn eeste bericht",
     209  unTranslatedString1: "some string",
     210  ignoredObject: {
     211    translatedString2: "mijn tweede bericht",
     212    unTranslatedString2: "some string"
     213  },
     214  translatedObject1: "mijn derde bericht",
     215  translatedObject2: "lijst, van, strings",
     216}
     217}}}
     218