Skip to content

Latest commit

 

History

History
101 lines (63 loc) · 1.47 KB

localizable.js.md

File metadata and controls

101 lines (63 loc) · 1.47 KB

localizable.js

The localizable.js utility automatically translates localization literals depending on the current language of the application user.

Usage

Include the localizable.js utility on your View.

<script src="/scripts/frapid/utilities/localizable.js"></script>

Example

The localizable.js investigates html controls having the following attributes:

  • data-localize
  • data-localized-placeholder
  • data-localized-title

data-localize

This

<div class="ui message">
    <span data-localize="CompanyName"></span>
</div>

will be converted to (English)

<div class="ui message">
    <span>Company Name</span>
</div>

or (German)

<div class="ui message">
    <span>Firmenname</span>
</div>

data-localized-placeholder

This

<input data-localized-placeholder="Customer" />

will be converted to (English)

<input placeholder="Customer" />

or (German)

<input placeholder="Kunde" />

data-localized-title

This

<input data-localized-title="Customer" />

will be converted to (English)

<input title="Customer" />

or (German)

<input title="Kunde" />

Translate a Localization Key Using Javascript

To translate a given key to the current language, you can use a window function called translate. Example:

window.translate('Customer')//Kunde in German

Back to Internationalization