1.7 Localization Changes

35 views
Skip to first unread message

fyrye

unread,
Jun 4, 2010, 7:21:53 PM6/4/10
to MooFloor
Hey all,

We've made some major changes to the localization system.

The new features are that Localization has been separated from the
FormCheck core.
And is it's own separate class. FormCheck.Locale

It utilizes Request.JSON, so instead of having to supply a <script>
asset to the language you want to load you tell formcheck where your
language repository is;
EG: http://mydomain.com/formcheck/lang or /formcheck/lang
And it will load the definitions automatically for you when you
initialize FormCheck (var fc = new FormCheck())

The Localization script will also automatically attempt to detect the
viewers language and region. EG: en-US.
If one can not be found it will fall back to the 'default' you supply.
And if for any reason it fails it uses the internal localization
inside of FormCheck.

The Localization also now supports cascading alerts, (definitions)
where it can load several different language files to fill in missing
alerts for the user's language-region.

How this affects you:
The new localizations must be in a valid JSON format.
And their file names must be in the named language - region .json
EG: en-US.json and ja-JA.json
The alerts inside of the json file are now stored inside of
"definitions" and are no longer inside of a variable object
{
"definitions" : {
"required": "This field is required."
}
}

Cascading support:
In order to support cascading for a particular language all you simply
need to do is to supply a "cascade" entry in the json file of the
current language for the language you want to load after the current
language.
So if the user's language is en-US, your en-US.json file may look
like:
{
"cascade" : "en-EN",
"definitions" : {
"required": "This field is required."
}
}
Which will tell the script to load en-EN after loading en-US.
Where the definition for required will stay as en-US's definition,
even if en-EN has a definition for required.

The options:
Several new options are available for the localization in 1.7.
When setting up a new formcheck you can set these options under locale
like so:
vr fc = new FormCheck({
submit: false,
locale: {
url: '/formcheck/lang',
cascade: true,
'default': 'en-EN',
lang: false
}
});

Explanations:
url - (string) defines the url to check for the language files
cascade - (boolean) enables or disables cascade support, false will
only load the current language file
'default' - (string) The default language to fall-back to if the
current language can not be found.
lang - (string || false) The language to set the current language
to, false auto-detects the viewers language.

If you have any questions or comments, please feel free to post them
here.
Keep watching this post for updates regarding the upcoming tips
feature as well.

moose

unread,
Jul 19, 2010, 1:29:30 PM7/19/10
to MooFloor
By the way, the german translation for "lengthmax" and "lengthmin"
isn't very good.
This translation would be better:
lengthmax: "Der Wert ist nicht korrekt, es d&uuml;rfen maximale %0
Buchstaben sein.",
lengthmin: "Der Wert ist nicht korrekt, es m&uuml;ssen minimal %0
Buchstaben sein.",

moose

unread,
Jul 19, 2010, 1:32:49 PM7/19/10
to MooFloor
Oops, sorry, even better would be:
lengthmax: "Der Wert ist nicht korrekt, es d&uuml;rfen h&ouml;chstens
%0 Buchstaben sein.",
lengthmin: "Der Wert ist nicht korrekt, es m&uuml;ssen mindestens %0
Buchstaben sein.",
Reply all
Reply to author
Forward
0 new messages