Localization in Ext JS

Source: Internet
Author: User
Tags fecha locale setting

Ext JS comes bundled with a localization package the supports over-languages ranging from Indonesian to Macedonian, an D It ' s simple to implement.

Ext JS includes an international module with about 40 languages, from Indonesia to Macedonia, and is very easy to implement.

1. Locales

You'll find all of the bundled locales files in the Override folder of the Ext-locale package. Locale files is just overrides that's Ext JS to replace the default 中文版 values of certain components. These is generally things like date formats, month and day names, etc.

You can find a lot of international files are placed under the Ext-locale directory, which can be used to replace the default English characters, such as date format, month, day name and so on.

The date picker is a perfect example. Here's a excerpt from the Spanish localization file:

For example, date selection is a good example of what you can see from its Spanish files:

 ext.define ("Ext.locale.es.picker.Date"  "Ext.picker.Date" Span style= "COLOR: #000000", Todaytext:  "Hoy"  "Esta fecha es a Nterior a la fecha mínima "" Esta fecha es posterior a la fecha máxima "
     
       "" "
       ""  ' Mes siguiente (control+right) ' , Prevtext :  ' mes anterior (control+left) '  ' seleccione un Mes (Control +up/down para desplazar el a?o) '  ' {0} (Barra espaciadora) ' 
     
2.Localization with Sencha CMD

To implement localization, simply modify the app.json file in your Sencha CMD generated application. You'll want to add the "Ext-locale" package to the requires block. The resulting addition should look like this:

In order to internationalize, you need to make some changes to the App.json in the program directory you created through the Sencha cmd command. First you need to add a Ext-locale module. Add the following:

/* * * The List of required packages (with optional versions; default was "latest"). * * For example, * *      "requires": [*          "sencha-charts" *      */"Requires":    ["Ext-locale"], 

Your application is now ready for localization. The next step is to determine the language, that's interested in including. All the need to does is create a locale setting. Simply Add the following line to your app.json file:

Now that your program is internationalized, you need to specify the language you want. All you need to do is add the following in the App.json file:

"Locale": "Es",

3.Localization without Sencha CMD

The simplest-localize Ext JS without Sencha CMD is-to-include the locale file in your index file.

The simplest way to achieve internationalization is to add code directly to your index.html file:

<!DOCTYPE HTML><HTML><Head>    <!--ensure we ' re using UTF-8 -    <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">    <title>Localization Example</title>    <!--Main Ext JS files -    <Linkrel= "stylesheet"type= "Text/css"href= "Resources/ext-theme-neptune-all.css">    <Scripttype= "Text/javascript"src= "Ext-all.js"></Script>          <!--Include the Translations -    <Scripttype= "Text/javascript"src= "Ext-locale-es.js"></Script>    <Scripttype= "Text/javascript">Ext.onready (function() {ext.create ('Ext.picker.Date', {renderTo:Ext.getBody ()});    }); </Script></Head><Body>
4.Localizing your Ext JS Extensions

You'll want to ensure so follow Ext JS best practices for localization when you write a custom component or plug-in. At the very minimum, every text string that's shown to users should is defined as a property:

You might want to make sure that if you write a form or plugin yourself, how to internationalize:

Ext.define ("Ext.ux.Weather", {    "It's a nice sunny day",    "Bad Weather, Don's Go Out",      Other code ...});

Localization in Ext JS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.