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 …).

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.
Hello, your Locale Modules for iOS are very interessting. Are you going to update them to support iOS 64 bit. Thank you!
Soon I will update 64 bit module.. Sorry for the delay…!
when you’re done, we look forward to your short message… Thank you!
Hi, any progress on the 64-bit so far..
Please, update them to x64 bits!! I need these modules for my new projects!!
I will update 64 bit module.. Sorry for the delay…!
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.
Hi @ketanmajmudar:disqus
Can you please check in store for latest updated.
I updated link in above comments.
Ref:
https://marketplace.appcelerator.com/apps/7209?restoreSearch=true#!overview
Thank you,
Naga Harish.
We are using your Locale modules for iOS. Can you update them to 64-bit and PM me?
Please update the iOS module for 64-bit support. Thanks
Sorry but is the update difficult or you don’t have time? We can help!
64-bit version ready? – We need it.
Thanks, great module ! Do you need help for 64-bits support ? I can help you with the process.
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 🙁
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.
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.
Thanks! Please add to github.
Hi Can you please use Top Market place link.
Top Market place link – application is not available.
I am sorry. With my login I can see. Anyway I will Drop a shared link with .ZIP access
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!
Wow! here is the iOS 64-bit module https://marketplace.appcelerator.com/apps/7151?755988831#!overview
https://onedrive.live.com/redir?resid=e3de788e0c35d3ae%2187307 use this link
Thanks for the support!
The file behind the OneDrive link does not seem to be shared. Or do I have to create a Microsoft account to download it?
https://onedrive.live.com/redir?resid=E3DE788E0C35D3AE%2187308 try this
Thank you so much! 🙂
resetLocale() doesn’t work on iOS.. undefined is not a function..
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!
In the Android module i am also getting an error
It seems this is not module related error. can you please check in sample…
You are totally right.. Very sorry!!
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.
Small correction. I have en, es, pt-rBR and pt-rPT
Hi,
May be something issue with other language. Please check post
https://wiki.appcelerator.org/display/guides2/Internationalization
They are saying only ISO 639-1
http://en.wikipedia.org/wiki/ISO_639-1
I will do R&D on this. If I got any solution i will let you know.
Thank you.
Yeah, the guide says that but I got country code working with the default phone language both in android and iOS. It is still very badly supported but it works. The language change doesn’t work on android though.
Ok please do me one thing. Just change in phone settings and try to print locale (use http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Locale-property-currentLocale ). and also use this module and set locale and print locale. Check if both are same or not.
Hi, sorry to bother again.
Any idea how to solve this?
Do you have this in github?
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
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.
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
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.
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
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)…
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
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.
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
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.
“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?
please use https://marketplace.appcelerator.com/listing?q=locale
and search for locale
Can i get for free version on Ti 6.0 SDK? Thanks.
You can give try, trial is free. Please let me know if you need any help from my side.