
Kung Hei Fat Choy! Do you know what it means in Cantonese? Ever thought of learning Cantonese could be fun and easy? As we come from Hong Kong, we decide to bring you something local this week – Cantonese Bot which teaches people Cantonese.
It seems that there are rapid discussions on language globalization on the internet. Recently, we have come across a similar question: how to deploy to different currencies according to the users’ locations? Here’s how it works in Meteor:
First, you should install this plugin by typing this line in the root of project on console:
1 |
meteor add cordova:cordova-plugin-globalization@1.0.2 |
This plugin obtains information and performs operations specific to the user’s locale, language, and timezone.
Then, you have to create a code which suits your needs and purposes. Put this globalization code in ** lib.js**.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
var currConveter = { "ZH-HK": { A: "HKD 8" }, "ZH-TW": { A: "TWD 30" } } if (Meteor.isClient) { document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { console.log(navigator.globalization); // starting from here, do whatever you want navigator.globalization.getPreferredLanguage( function(language) { alert('language: ' + language.value + 'n'); Meteor.currency = language.value; if (!_.has(currConveter, Meteor.currency)) Meteor.currency == "ZH-HK"; }, function() { alert('Error getting languagen'); } ); } } |
You may click here to learn more about the code.
You can start your login in line 21. There are a few points to note: firstly, you may hardcode the currency unit for your different products or options; secondly, you should set location checking to check the location of the user; thirdly, you should set a default currency in case the user is not in the location list you have set.
Last but not least, you must change your locations in your phone setting so as to be successfully detected by the app. After that, it will display the currency unit according to the location setting in your phone.
For more information, you may also refer to here. We will continue to discuss the deployment to payment gateway in globalization in Meteor.