The localizable.js utility automatically translates localization literals depending on the current language of the application user.
Include the localizable.js utility on your View.
<script src="/scripts/frapid/utilities/localizable.js"></script>
The localizable.js investigates html controls having the following attributes:
- data-localize
- data-localized-placeholder
- data-localized-title
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>
This
<input data-localized-placeholder="Customer" />
will be converted to (English)
<input placeholder="Customer" />
or (German)
<input placeholder="Kunde" />
This
<input data-localized-title="Customer" />
will be converted to (English)
<input title="Customer" />
or (German)
<input title="Kunde" />
To translate a given key to the current language, you can use a window function called translate
. Example:
window.translate('Customer')//Kunde in German