1
0
-1

For example, for cities in a country, I have a form and a crud userview for crud operations on cities. In various forms users may select a city from a dropdown list. So far I made it work.

But:

for Tripoli in Libya, Arabic speakers will see طرابلس, and English speakers will see "Tripoli" on pages.

But "tripoli" is not a label on a form, so i18n hash variable does not work (I entered #i18n.tripoli# as city name in database, and entered appropriate message values but it does not work).

How can I make such a localisation that when users change locale, such data from database changes language too?

    CommentAdd your comment...

    3 answers

    1.  
      1
      0
      -1

      Dear ufuk,

      The other easy way to solve your problem is

      In your Database config 3 cols, city, enLabel, arLabel

      and create 2 drop downList with same ID, 1 display city as enLabel and 1 display as arLabel in 2 different Section

      and at the permission of Section Check Is that section for the Current Locale if not invisible it

       

      Best Regards

      Tony Chu

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Dear ufuk,

        I will still use Joget drop down List (city), as we need to leverage the Joget Form to save the data.

        Here is some idea from me.

        First setup the List of Message with Message ID like "city_<cityName>"

        So your sample : will be city_tripoli

        and your database should have a field to store the label as  city_tripoli also.

        Then we may apply the following Code

        $(document).ready(function(){
        	// Code here to use AJAX to get the label from app_message (sync Mode)
            // parameters : the localeCode and the prefix of City 
            // Query: select messageKey, message from app_message where appId=? and appVersion = ? and locale = ? and messageKey like ("city_%");
            // return full city list as Json array
        	
        	//Then execute the code below after get the data return
        	
        	$(FormUtil.getField("city")).find("option").each(function(){
        		var orgLabel = $(this).text();
        		// code here to get the newLabel from the result List by matching orgLabel = messageKey
                $(this).text(newLabel);
        	});
        });

        Hope this help! 

        My2Cent

        Tony

          CommentAdd your comment...
        1.  
          1
          0
          -1

          Dear ufuk,

          To me, it does not make sense to localize all data in the database, If you want it, I think Goolgle Translate may be 1 choice for you.

          If you want to localize for certain specific fields, I think you just can leverage dropdown list as you need to control what the users entered will have the localized string configured.

          Best Regards

          Tony Chu

          1. ufuk yilmaz

            Hi! It doesn't have anything to do with Google Translate. Simply the question is: how do you change the language of options in a dropdown list when a user changes his locale?

          2. Tony Chu

            Ok, In this case, What I can think you may need to have a jquery to rebuild the label for the "Selecbox" by custom a ajax function to query the table "app_message".

          3. ufuk yilmaz

            so you mean, don't use joget's own dropdown, construct it yourself using jquery based on current locale? assuming you can access current locale setting from jquery?

          CommentAdd your comment...