Type class
Handles all language-related tasks, like loading and storing translations, translating prompts, lists of prompts and even functions.
Almost every object in amCharts4 universe will have a language
property, which can be accessed for prompt translation.
ILanguageAdapters
for a list of available Adapters
@todo Make prompt keys case-insensitive
Sources
Language can be used (imported) via one of the following packages.
/** * -------------------------------------------------------- * Import from: "core.ts" * Use like: am4core.Language * -------------------------------------------------------- */ import * as am4core from "@amcharts/amcharts4/core";
/** * -------------------------------------------------------- * Include via: <script src="core.js"></script> * Access items like: am4.Language * -------------------------------------------------------- */
Inheritance
Language extends BaseObjectEvents
.
Language is not extended by any other symbol.
Properties
adapter # |
Type Default Adapter. |
---|---|
clonedFrom # |
Type Inherited from Reference to the original object this object was cloned from. We need to keep this so we can disassociate it from source object when this object is disposed. |
config # |
Type Inherited from Use this property to set JSON-based config. When set, triggers processing routine, which will go through all properties, and try to apply values, create instances, etc. Use this with caution, as it is a time-consuming process. It's used for initialchart setup only, not routine operations. |
events # |
Type Inherited from An |
id # |
Type Inherited from Sets the user-defined id of the element. |
locale # |
Type Current locale. |
uid # |
Type Inherited from Returns object's internal unique ID. |
There are 5 inherited items currently hidden from this list. |
Methods
clone( cloneId?: ) |
Returns Inherited from Makes a copy of this object and returns the clone. Try to avoid cloning complex objects like chart, create new instances if you need them. |
---|---|
constructor() |
Returns Constructor |
copyFrom( source: ) |
Returns Inherited from Copies all parameters from another |
dispatch( eventType: ) |
Returns Inherited from Dispatches an event using own event dispatcher. Will automatically populate event data object with event type and target (this element). It also checks if there are any handlers registered for this sepecific event. |
dispatchImmediately( eventType: ) |
Returns Inherited from Works like |
dispose() |
Returns Inherited from Destroys this object and all related data. |
getCurrentThemes() |
Returns Inherited from Returns a list of themes that should be applied to this element. It could either be a list of themes set explicitly on this element, or system-wide. |
isDefault() |
Returns Returns |
isDisposed() |
Returns Inherited from Returns if this object has been already been disposed. |
setTranslationAny( prompt: ) |
Returns Sets a prompt translation. @since 4.9.35 |
translate( prompt: ) |
Returns Returns the translation of the string. If the translation is empty, it will return untranslated prompt. Third parameter and up are strings that can be used to replace "%X" placeholders in prompt. E.g.: // Results in "This is a first translation test" chart.language.translate("This is a %1 translation %2", null, "first", "test"); // Results in "This is a first translation test" chart.language.translate("This is a %1 translation %2", null, "first", "test"); |
translateAll( list: ) |
Returns Translates a list of prompts in one go. |
translateAny( prompt: ) |
Returns Non-type-checked translation. Can be used by plugins and other code that may have their own non-standard translation prompts. @since 4.5.5 |
translateEmpty( prompt: ) |
Returns Translates prompt. If translation is empty, it will return empty string, which is a different behavior than that of regular |
translateFunc( prompt: ) |
Returns Translates a function. This method will return a function reference, but will not run it. It's up to the caller script to run the function. @todo Apply adapter |
There are 7 inherited items currently hidden from this list. |
Events
#localechanged |
Param { locale: Invoked when locale is changed by user. |
---|
Adapters
#locale |
Param { locale: Applied to result whenever retrieving currently set locale. |
---|---|
#translate |
Param { locale: Applied to a translation. |
#translations |
Param { locale: Applied to all of the locale translations. |