• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

darksmo/jquery-localization-tool: Simple localization dropdown for your website. ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

darksmo/jquery-localization-tool

开源软件地址(OpenSource Url):

https://github.com/darksmo/jquery-localization-tool

开源编程语言(OpenSource Language):

JavaScript 90.7%

开源软件介绍(OpenSource Introduction):

jquery.localizationTool.js

Simple localization dropdown for your website. Translates strings in the languages you provide. This widget is built with the single page scenario in mind. It supports right-to-left text direction when languages like Arabic are selected.

Build Status

Example

Initialize with:

<div id="localizationToolbar"></div>

<div id="someId">Original string goes here</div>
$("#localizationToolbar").localizationTool({
    strings : {
        'id:someId': {
            'it_IT' : 'Italian translation here',
            'de_DE' : 'German translation here',
            'fr_FR' : 'French translation here',
            'es_ES' : 'Spanish translation here',
            'en_AU' : 'Australian english translation here',
            'pt_BR' : 'Portuguese translation here',
            'en_GB' : 'British english translation here',
            'jp_JP' : 'Japanese translation here',
            'ar_TN' : 'Arabic translation here',
        },
        /* ... more strings can follow */
    }
});

Destroy with:

$("#localizationToolbar").localizationTool('destroy');

Demo

For live demos please visit the project webpage:

http://darksmo.github.io/jquery-localization-tool/

For a Quick Start, step-by-step guide, have a look at the source html of the following file:

https://github.com/darksmo/jquery-localization-tool/blob/master/demo/index.html

Options

Option Type Default Description
defaultLanguage string en_GB the language_country code the page to translate is initially in.
languages object {} additional/custom language definitions
strings object {} pointers to the original strings and their translations in various languages
showFlag boolean true whether to show the flag on the widget
showLanguage boolean true whether to show the language name on the widget
showCountry boolean true whether to show the country name on the widget
onLanguageSelected function function (/*langCountryCode*/) { return true; } a callback called as soon as the user selects the new language from the dropdown menu. Return true to trigger the translation or false to just select the language without translating.
ignoreUnmatchedSelectors boolean false do not throw error if a provided selector doesn't match the html markup
labelTemplate string {{country}} {{(language)}} a template string to interpolate with actual values for language and country. The {{language}} and {{country}} tokens will be replaced if present in the template string. Also it's possible to add prefixes/suffixes inside the curly braces, as the paretheses in the default value.

Methods

Method Argument Description
translateString string (textToTranslate), string (languageCode) translates the given textToTranslate in the given languageCode. Note, this method just translates without creating side effects, returning the translated string.
translate string (languageCode) translates the text in the DOM to the given language programmatically, if no language code is specified, the default (initial) translation is used.
destroy None destroys the localization tool

JSDoc

See index.html in docs/ directory

Dependencies

jQuery 1.6.4+

License

Copyright (c) 2014 Savio Dimatteo

Licensed under the MIT license.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap