Skip to content

Internationalization & Localization

pradhanaindra edited this page Feb 9, 2014 · 2 revisions

Unmask supports i18n & l10n, although the feature is still tightly coupled to the source code. To add support for your language, you need to edit the source code (unmask.js) directly.

Currently Unmask provides built-in supports for English and Indonesian.

Note: If you just want to use your locale without edit the source code, you also can provide the locale texts every time you call Unmask.init. Check documentation of function Unmask.init and its parameter, userOptions.toggleLabelText and userOptions.unmaskConfirmationText.

How to add localization for other languages

Open file unmask.js.

Add text for label of "unmask password" button. Add new object (as name-value pair) to Unmask.prototype.toggleLabelText.

Format

<ISO-639-2 code of the language> : {
	masked : <Label of the button when password is masked. It should tell user to press this button if she want to unmask and see her password as plain text>,
	unmasked : <Label of the button when password is unmasked. It should tell user to press this button if she want to mask her password>
}

Example: you add localization for German. Unmask.prototype.toggleLabelText should become:

Unmask.prototype = function() {
...
var toggleLabelText = {
	eng : {
		unmasked : 'Hide password',
		masked : 'See password'
	},
	ind : {
		unmasked : 'Sembunyikan',
		masked : 'Lihat password'
	},
	deu : {
		masked : 'Siehe Passwort',
		unmasked : 'Verbergen'
	}
};
...

Then add text for confirmation dialog message that displayed first time the user use "unmask password" button. Add new name-value pair to Unmask.prototype.unmaskConfirmationText.

Format

<ISO-639-2 code of the language> : <Confirmation dialog message displayed to user when she click "unmask password" button for first time>

Example: you add localization for German. Unmask.prototype.unmaskConfirmationText should become:

Unmask.prototype = function() {
...
var unmaskConfirmationText = {
	eng : 'Your password is going to be shown as plain text. For your security, please ensure no one see. Unmask your password now? (This message only appear once)',
	ind : 'Password anda akan ditampilkan sebagai teks biasa. Demi keamanan anda, pastikan tidak ada orang lain yang melihat. Tampilkan sebagai teks biasa sekarang? (Pesan ini hanya muncul 1 kali)',
	deu : 'Wir werden Ihr Passwort als Klartext anzeigen. Für die Sicherheit Zweck, stellen Sie bitte sicher niemand sehen kann. Zeigen Sie Ihr Passwort jetzt? (Diese Meldung nur einmal angezeigt)'
};
...

Note: German in examples above are translated using Google Translate. If the translations are inaccurate, confusing, or funny... please tell us... after you finish laughing :D

Clone this wiki locally