Labs/Jetpack/JEP/35
From MozillaWiki
Contents
JEP 35 - Internationalization/Localization API
- Champion: Zbigniew Braniecki <gandalf at mozilla dot com>
- Status: Planning/Experimenting
- Type: API Track
- Created: 9 Dec 2009
- Reference Implementation: None
- JEP Index
Introduction and Rationale
This JEP describes Internationalization API for the Jetpack API.
Jetpacks expose UI which has to be localizable and we currently do not provide any model for internationalization of jetpacks.
Proposal
Localization API will be accessible via jetpack.l10n
.
Accessing entity
jetpack.l10n.addResource('/path/to/file') var x = jetpack.l10n.getValue('ID')
- ID - ID may be similar to DTD ones - newTabCmd, but we may also want to support source string in a form of jetpack.l10n.getValue('Hello world!') that will be later extracted and properly localized.
UI widgets
new jetpack.ui.Button({ label: 'Hello world', accesskey: 'k', tooltip: 'click me!', command: function(n){} })
- In this case, we would like to allow developers to write their code without having to separately think about localization. We will extract the label, and replace it with localized content.
- We should be able to automagically assign accesskey and tooltip from localization file.
Entity bindings
jetpack.l10n.bindEntity('entity_id',vars,place)
- entity_id - ID of the entity
- vars - Array or object of variables used by entity (number of emails, name of a person etc.)
- place - DOM handler to the place where the entity should be displayed
In this scenario we will bind the place, entity and list of variables and will update the string whenever there is a change to any vars element. We will also be able to switch the locale on fly.