Titanium Locale Module for Both (Android and iOS)

In this post I am going to introduce to Locale module. This module helps to force the phone language only in your application. And you can just follow same i18n folder with your locale strings XML files (For example :- “en” folder >  strings.xml …).

Locale Titanium module

Locale Titanium module

To load Locale module into your app, write below one line code.
var locale = require("com.shareourideas.locale");

After loading you need to force locale in your application, just call setLocale method with language.
locale.setLocale("es");

This above code helps to refer Spanish locale strings. Then if you try some thing like this.
Ti.API.info("This is just for test" + L("welcome_message"));

It will print Spanish locale string (from “es” folder > strings.xml). To get current locale you can use default Titanium property Ti.Locale.currentLanguage.

You can see example code in module folder and documentation as well. By the way make sure you tested your app after adding this locale module.

This module is free to trial and available for both Android and iOS from Appcelerator Titanium marketplace. Here are the download links.

  • Pingback: This Week in Titanium Mobile Development: 9 Dec 2013 | Titanium Development()

  • Pingback: This Week in Titanium Mobile Development: 9 Dec 2013 | TiDev()

  • Le Minh

    Hello, your Locale Modules for iOS are very interessting. Are you going to update them to support iOS 64 bit. Thank you!

    • http://shareourideas.com/ Rish Movva

      Soon I will update 64 bit module.. Sorry for the delay…!

      • Le Minh

        when you’re done, we look forward to your short message… Thank you!

      • Srinivas

        Hi, any progress on the 64-bit so far..

  • Digitalico

    Please, update them to x64 bits!! I need these modules for my new projects!!

    • http://shareourideas.com/ Rish Movva

      I will update 64 bit module.. Sorry for the delay…!

      • Ketan Majmudar

        Any chance you could open source this module, as we would submit a PR to make this 64 bit compatible. We have some new apps that require this asap. Thanks.

  • Alex Foong

    We are using your Locale modules for iOS. Can you update them to 64-bit and PM me?

  • CMO

    Please update the iOS module for 64-bit support. Thanks

  • Le Minh

    Sorry but is the update difficult or you don’t have time? We can help!

  • urgent caller

    64-bit version ready? – We need it.

  • juanblo

    Thanks, great module ! Do you need help for 64-bits support ? I can help you with the process.

  • Anna Kozynenko

    We need to publish our application asap, and Appstore will reject it because the module is lacking 64-bit support. It takes 3 minutes to update, but there is no source code :(

  • Srinivas

    We are using your com.shareourideas.locale modules for iOS.
    While running on different simulator devices,It is working on few devices only not in all devices.
    We are getting below error.

    Script Error Couldn’t find module: com.shareourideas.locale for architecture: x86_64

    Please update the iOS module for 64-bit support.

  • http://shareourideas.com/ Rish Movva

    Hi All,
    We build for 64-bit support. Upload to Appcelerator market place also waiting for approval.

    If you need, please drop me your email ID in comment. so that I can help you.

    Thank you.

    • AND

      Thanks! Please add to github.

      • http://shareourideas.com/ Rish Movva

        Hi Can you please use Top Market place link.

        • AND

          Top Market place link – application is not available.

          • http://shareourideas.com/ Rish Movva

            I am sorry. With my login I can see. Anyway I will Drop a shared link with .ZIP access

    • rjgijsbertsen

      Hi we also need a 64-bit version of this module asap. Could you upload to Github or mail me at robert-jan at media-artists dot nl? Thanks!

  • http://shareourideas.com/ Rish Movva
  • http://shareourideas.com/ Rish Movva
  • Steffanb

    resetLocale() doesn’t work on iOS.. undefined is not a function..

    • http://shareourideas.com/ Rish Movva

      I will check and get back you. If any problem I will update the build.

      For now try use setLocale method and pass some dummy chars.. and try!

      • Steffanb

        In the Android module i am also getting an error

        • http://shareourideas.com/ Rish Movva

          It seems this is not module related error. can you please check in sample…

          • Steffanb

            You are totally right.. Very sorry!!

  • Filipe

    Hi, sorry to ask for help here, but I couldn’t find another way. Is it a bug or I’m doing something wrong that I can’t change locale using country codes in android. I have en, us, pt-rBR and pt-rPT locales. They work fine using the system locale but when I try to change it does nothing for the pt languages. I’ve tried multiple things (pt, pt-BR, pt-rBR).
    In iOS it works fine, the folders are differente but the module changes correctly.

    • Filipe

      Small correction. I have en, es, pt-rBR and pt-rPT

  • Altaf Hussain

    Hi,
    I am thinking of purchasing this module for one of my application, but before i do, I have a few questions. Hopefully I will get reply as soon as possible:

    1) Is this module compatible with Alloy?
    2) Can we use titanium L method with this module?
    3) If I buy this module, it will work for a single application and does not matter how many times that application is installed?
    4) Is this module compatible with latest SDK 5.x?
    5) Can i use this module to change the application language without reloading the complete application? I mean in-app language change?

    Kindly reply me asap.

    Thank you

    • http://shareourideas.com/ Sri Movva

      Hi @Altaf Hussain ,
      First Thank you for buying!

      1) Yes, It will work same you have to use titleid textid in .tss and .XML or L(“STRING_NAME”) in .tss, .js

      2) Yes L method only helps to return string

      3) Yep, current policy is like that only. I hope this policy will not change.

      4) Recent tested with latest SDK and it works same.

      5) Yes, you no need to close the app and open again. But after changing the language, we have to re-render text, title values again.. then only it will effect.

      Thank you,
      Naga Harish.

      • Altaf Hussain

        Hello Naga Harish,
        Thanks for your eply. I did not understand the answer 5. Is not your module rendering the text, titles for the selected language itself?

        Thanks

        • http://shareourideas.com/ Sri Movva

          Hi @disqus_h6YAputdVm:disqus ,

          I mean, if windows is opened already UI will be render (displayed) and it will add title or text based on currently. After that if you changed locale lang and came back to this screen by click back button it will still show old rendered labels texts only. For that we need re open the window or just update labels based on locale changed. I will recommend to show loader saving applying changes… in background close the current window or nav group and open it again. Than it will work as it is.

          I hope you understand now. Feel free if you still need my help..!

          Thank you,
          Naga Harish.

          • Altaf Hussain

            Hi Naga Harish,

            What about the currently opened window, on which I change the language? Will it be displayed in the selected language when the language is changed, or I have to reload it also?

            Thank

          • http://shareourideas.com/ Sri Movva

            You have to reload.. That is what I want to saying.. But I am missing somewhere.. (It is not possible, because ui already render by OS on screen before you changing language)…

          • Altaf Hussain

            This is something i want to do, to reload the windows seamlessly so that the user of the app dont know. Like in native apps, or other apps, if you change the language, all titles are changed accordingly. They may be reloading the windows, but it is so seamless and fast that it does not effect the display.

            Do you think there is any module which can do this for me using that module with yours?

            Thanks

          • http://shareourideas.com/ Sri Movva

            I don’t think it is possible in native app also. with out reassigning value, title and texts to views.

            There is another without re opening windows:
            function init(){
            renderLocales();
            }

            /**
            Helps to render text, values and titles
            */
            function renderLocales(){
            $.label.text = L(“WELCOME”);
            }

            function onWindowFocus(){
            if(Alloy.Globals.localeChanged) //This localeChanged value will be true when user changed the locale in setting screen..
            renderLocales();
            Alloy.Globals.localeChanged = false;
            }

            or instead of window focus, you can also use Global event listeners.

            Think of those above approaches. Rendered UI can’t changed until reassign values to them again.

            Thank you,
            Naga Harish.

  • Christoph Eck

    Hi

    Could you please update your android module for Titanium SDK 6.0. There is a short step by step documentation at http://skypanther.com/2016/10/rebuilding-modules-for-titanium-6/

    Kindly reply me asap.

    Thank you

    • http://shareourideas.com/ Sri Movva

      Hi Dude,

      I updated the module to Appc store. They had issue with my account so removed my previous marketplace modules. And they asked me to upload newly. I did that one month back itself. Please subscribe new version Locale for Android and use. From two users I got personal feedback saying the new module works fine with Ti SDK 6.0.
      if you need more details please contact me in mail nagaharish.movva[@]gmail dot com

      Thank you,
      Naga Harish.

  • Ahmed Said

    “Found incompatible Titanium Modules” for android 0.1 version on Ti 6.0 SDK, can you give a download link for android version that works fine with Ti 6.0?

    • http://shareourideas.com/ Sri Movva
      • Tola Soy

        Can i get for free version on Ti 6.0 SDK? Thanks.

        • http://shareourideas.com/ Sri Movva

          You can give try, trial is free. Please let me know if you need any help from my side.