Results 1 to 7 of 7

Thread: How to implement Localization in Extjs 6.2 with Sencha architect 4.2

  1. #1
    Sencha User
    Join Date
    Jun 2014
    Posts
    82
    Answers
    1
    Vote Rating
    1
      0  

    Default How to implement Localization in Extjs 6.2 with Sencha architect 4.2

    Hi,

    How to implement Localization in Extjs 6.2 with Sencha architect 4.2?

    Thanks and Regards,
    Ganesh. R

  2. #2
    Sencha User
    Join Date
    Sep 2014
    Location
    Central Europe
    Posts
    795
    Answers
    103
    Vote Rating
    52
      0  

    Default

    There is no "direct" support for localization inside SA but you should be able to do localization in the same way you do it for normal ExtJS apps https://docs.sencha.com/extjs/6.2.0/...alization.html

  3. #3
    Sencha User
    Join Date
    Jun 2014
    Posts
    82
    Answers
    1
    Vote Rating
    1
      0  

    Default

    Quote Originally Posted by petr.vecera View Post
    There is no "direct" support for localization inside SA but you should be able to do localization in the same way you do it for normal ExtJS apps https://docs.sencha.com/extjs/6.2.0/...alization.html

    Hi,

    Thanks much for your reply..

    Now

    I am using Extjs 6.2 with Sencha Architect 4.2.1.
    I need to use localization in our application.

    I have done below code for localization .
    Ext.define('Test',{
    singleton:true,
    insert:'<u>I</u>nsert' });

    I need to use use this code in my view file like

    requires:['Test.js'],
    items:[{
    xtype:'button',
    text:Text.insert
    }]

    The above code is working fine in when I have using webapp folder.

    But if I write in inside of sencha architect, it will take string in text below code like.

    requires:['Test.js'],
    items:[{
    xtype:'button',
    text:'Text.insert'
    }]

    So it will come in button Text.insert as as string.

    so can you please help anyone, how to use variable value in button text using sencha architect.

    Thanks and Regards,
    Ganesh. R

  4. #4
    Sencha User
    Join Date
    Sep 2014
    Location
    Central Europe
    Posts
    795
    Answers
    103
    Vote Rating
    52
      0  

    Default

    This is quite problematic. If you are not able to do it using data binding and viewmodel you would have to use some kind of workaround, for example these https://www.youtube.com/watch?v=lLmLD3unWO4

  5. #5
    Sencha User
    Join Date
    Dec 2008
    Location
    France
    Posts
    291
    Answers
    3
    Vote Rating
    2
      0  

    Default Some sreenshot to show how to proceed with process config

    I've searched for long time to localize my app.
    Some different post found and i've tested different solutions.
    Finally, i did like described here.

    Here's screenshot to see how to proceed.

    1. Select the object (like a textField) and add a Process Config (click on the +)
    local1.png

    2. You will see some change on the object (in this example : me.processLogin)
    local2.png

    3. Click on the left_to_right arrow to go to the declaration of the process funtion and add the field for trnalsation (in this example : config.fieldLabel = Localization.login
    local3.png

    4. Don't forget to declare your translation file. I add a js resource in Sencha Architect
    local4.png

    local5.png

    The translation does'nt appear in the Sencha Architect Window.
    You need to save and load the app in the browser to see the translation.

    You need to compile as many app as locale of your project...
    Maybe it's possible to include all locale in the app and add some initialisation in the launch with the locale parameter.
    I will try this later.

  6. #6
    Sencha User
    Join Date
    Dec 2008
    Location
    France
    Posts
    291
    Answers
    3
    Vote Rating
    2
      0  

    Default

    If you want your translation data coming from server, you can do as described in https://www.sencha.com/blog/internat...-sencha-ext-js.


    • For the client side

    In Sencha Architect, add a js resource for the class declaration :

    Code:
    Ext.define('Localization', {
        singleton: true    
    });
    In the launch part of your app, request the translation data before the initial view :

    Code:
    launch: function() {
       Ext.Ajax.request({
                url: 'path/to//the/file/localization.php',
                params: {
                      locale: 'fr'
                },
                callback: function (options, success, response) {
                      var data = Ext.decode(response.responseText, true);
                      Ext.override(this.Localization, data);
                      Ext.create('MyApp.view.MyInitialView');
                }
      });
    }

    • For the server side (in the php way)

    The datas must be sent in json format.

    One file for each localization, like fr.php
    Code:
    <?php
    $lang_array['fr'] = [
             "LOGIN"                             => "IDENTIFIANT"
        ];
    ?>
    One script to generate the json data : localization.php

    Code:
    <?php
    $locale = "fr";//On définit la locale par dafaut à fr
    if (isset($_POST['locale']) && $_POST['locale'] != "") {
       $locale = $_POST['locale'];
    }
    include $locale.'.php';
    echo json_encode($lang_array[$locale]);
    ?>
    fr.php and localization.php in the same folder.


    By proceding like this, no need to compile as many Architect app as languages.
    The fr.php, en.php, it.php, etc... can be share with the client code and the serveur code.
    Only on file per language to maintain.



    Hope it can help some of you.

  7. #7
    Sencha User
    Join Date
    Dec 2008
    Location
    France
    Posts
    291
    Answers
    3
    Vote Rating
    2
      0  

    Default

    I forgot this.

    For the config to localize in your Extjs part, do this kind of declaration:
    Code:
    title: Localization.LOGIN

Similar Threads

  1. How to change the Localization in Sencha Architect 3.x?
    By teriandev in forum Sencha Architect 3.x: Q&A
    Replies: 3
    Last Post: 17 Dec 2014, 2:28 AM
  2. Sencha Architect and Localization
    By alexander.urban in forum Sencha Architect 3.x: Q&A
    Replies: 9
    Last Post: 14 Aug 2014, 8:33 PM
  3. How to implement a VCS in Sencha Architect 2 ?
    By bts in forum Sencha Architect 2.x: Help & Discussions
    Replies: 3
    Last Post: 28 Sep 2012, 1:11 PM
  4. How to implement the 'uses=[]' config property with Sencha Architect 2
    By stevenarcher in forum Sencha Architect 2.x: Help & Discussions
    Replies: 1
    Last Post: 8 Jun 2012, 4:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •