Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/technohippy/m17n.js
Simple M17N library for JavaScript
https://github.com/technohippy/m17n.js
Last synced: 21 days ago
JSON representation
Simple M17N library for JavaScript
- Host: GitHub
- URL: https://github.com/technohippy/m17n.js
- Owner: technohippy
- Created: 2009-11-09T16:55:20.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2009-11-09T18:20:50.000Z (over 15 years ago)
- Last Synced: 2024-11-24T22:41:50.444Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 70.3 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
M17N.js
=======M17N.js is a simple multilingalization library for JavaScript.
How to Use
----------### Functions
- M17N.setLocale(locale) : the given locale is stored in cookie and the value is used as default next time
- M17N.translate(key) : translate key into M17N.locale languate
- M17N.insertTranslate(key) : insert translated words at the position of the script tag.
- t(key) : alias of M17N.translate(key)
- it(key) : alias of M17N.insertTranslate(key)### Special ClassName
If you add a special classname (directed M17N.className and its default is `t') to an element, its innerHTML is automatically translated.
Sample
------
M17N.js sample
M17N.resources.ja = {
greeting: "ご挨拶", hello: "こんにちは",
en: "英語にする", ja: "日本語にする"
};
M17N.resources.en = {
greeting: "Say Greetings", hello: "Hello",
en: "English", ja: "Japanese"
};
greeting
en
ja
License
-------The MIT License
Copyright (c) 2009 Ando Yasushi ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.