Namespace for Internationalization API
Members
-
<static> language :string
-
Must be set to the desired lanuage. Defaults to english "en"
Type:
- string
-
<static> longMonths :Object
-
Sets the languages that that don't support shortening Translation will print entire month from locale for these languages
Type:
- Object
Methods
-
<static> convertCSV( [csv])
-
Converts a CSV array of translations into the required JSON format. You can output this to the console and paste back in if desired. Assumes that the header row of the CSV is the language codes and that the first column is the key language (English). Assumes non-quoted words.
Parameters:
Name Type Argument Description csvarray <optional>
Optional Translation spreadsheet in csv format. Make sure no leading tabs, trailing commas or spaces. Default is STX.I18N.csv
-
<static> findAllTextNodes( [root])
-
Returns a word list containing unique words. Each word references an array of DOM nodes that contain that word. This can then be used for translation. Text nodes and placeholders which are found in the document tree will be wrapped by this function within a
tag for easy translation back and forth. Parameters:
Name Type Argument Description rootHTMLElement <optional>
Optional root for the TreeWalker. If omitted, document.body assumed.
Returns:
A word list containing unique words.
- Type
- object
-
<static> missingWordList( [language])
-
STX.I18N.missingWordList will scan the UI by walking all the text elements. It will determine which text elements have not been translated for the given language and return those as a JSON object.
Parameters:
Name Type Argument Description languagestring <optional>
The language to search for missing words. Defaults to whatever language STX.I18N.language has set.
-
<static> printableMissingWordList( [language])
-
A convenient function for creating a human readable JSON object suitable for delivery to a translator.
Parameters:
Name Type Argument Description languagestring <optional>
Optional language. Defaults to STX.I18N.language.
-
<static> setLanguage(stx, language [, translationCallback] [, csv])
-
Convenience function to set up translation services for a chart and its surrounding GUI. It automatically sets STX.I18N.language, loads all translations and translates the chart.
Parameters:
Name Type Argument Description stxobject A chart object
languagestring For instance 'en'
translationCallbackstring <optional>
Function to perform Canvas Built-in word translations . Default is STX.I18N.translate
csvarray <optional>
Translation spreadsheet in csv format. Make sure no leading tabs, trailing commas or spaces. Default is STX.I18N.csv
- Since:
-
- 04-2015
-
<static> setLocale(stx, locale [, cb])
-
This method will set the chart locale using Intl natively or for unsupported browsers dynamically loads the locale using JSONP. Once the locale is loaded then the chart widget itself is updated for that locale. Use this function when a user can select a locale dynamically so as to avoid having to include specific locale entries as
scripttags. The optional callback will be called when the locale has been set. The Intl library includes JSONP for each locale. A zip of these locales can be requested and should be placed in the locale-data directory of your server.Parameters:
Name Type Argument Description stxobject A chart object
localestring A valid locale, for instance en-IN
cbfunction <optional>
Callback when locale has been loaded. This function will be passed an error message if it cannot be loaded.
-
<static> translate(word [, language])
-
Translates an individual word for a given language. Set stxx.translationCallback to this function in order to automatically translate all textual elements on the chart itself.
Parameters:
Name Type Argument Description wordstring The word to translate
languagestring <optional>
Optional language. Defaults to STX.I18N.language.
-
<static> translateUI( [language] [, root])
-
Passes through the UI (DOM elements) and translates all of the text for the given language.
Parameters:
Name Type Argument Description languagestring <optional>
Optional language. Defaults to STX.I18N.language.
rootHTMLElement <optional>
Optional root for the TreeWalker. If omitted, document.body assumed.