I want to know the best programming technique to switch languages in the software or website. So anyone can give me some suggestions? Thanks!
There is no standard. But I used the following technique in websites.
Put all the visible strings (eg. "file", "menu", "contact us") in a file or database. It can be xml, json or any format that you easily parse later. Make sure all the data is saved in different directory/db tables according to locale/language.
Wrap all the strings with a function or static class method. Every time they are displayed they'll go through some processing.
When you first load the software or web determine the locale or language that user wants to use.
According to users choice select the string source. database, filepath etc. For e.g. if user want to see strings in en_GB locale, find strings in en_GB folder or in lang_en_GB table. Naming format is in your hand.
Now each time the function or static class method is called find strings in the source you selected on Step 4.
It depends on the language you are using. Many have built in support for it. In android for example what you do is store all strings into an xml file that is named based on the region. And the operating system will automatically use the appropriate resources based on the phones region.
Look into what support your language/platform includes. You will want to externalize all your string constants such as "Press the menu button" into an external file. Then just get this file translated to each language you want to support, and use the OS to automatically use the correct resource file. Or if the platform/OS does not support such a thing write some code to determine which resource file to use yourself.
Related
How do we handle multi language requirements in our customisation? We can use suitescript API nlapiGetContext().getPreference('language') to retrieve the user preference.
My question is - what is the best practice to store the localized strings?
Should these be stored in multiple files in the file cabinet? Or should these be in a library module?
Is there a tighter support within NetSuite to handle this scenario?
In Netsuite you can use (For the backend) Custom Records (Customization > List, Records & Fields > Record Types > New) for storing the localized string which you can fetch in your suitelet or client script.
As long as it is a small string (or even for large) you can use custom records or there is another way you can use Email Template(Documents > Templates > Email Templates > New) for the same but here you need to create multiple files per language per string (I recommend this only for the long strings.)
Based upon the language you can compare and load the appropriate string.
You can fetch Email template using: nlapiLoadRecord('emailtemplate', 'template-id')
and Custom Records using: nlapiLoadRecord("record-id","row-id")
I the same problem, not being able to easily localise the language of NetSuite SuiteScript 2 scripts so I built my own language module that I just include in my scripts.
It allows you to separate all the text strings out of the actual coding so they can be easily updated / translated into any language.
Take a look at the project on my GitHub here:
https://github.com/mdbkaustralia/netsuite_language_controller_module
There is a short help doc in the readme, plus there is a working example you can upload to your NetSuite to try it out!
I'm working on a "cook book" app that has multiple (language) versions.
Apple says I can't upload multiple apps that are almost the same, so how can I achieve what is mentioned below in single app release ?
multiple languages (possible)
multiple logos (possible)
different "config" file for each language - e.g. file with API URLs
Each language version "separately" on App store so a user can download both english and spanish versions
My biggest problem is #4, it has to be possible that one can decide which language version he downloads.
You're most likely still looking at one app with multiple languages included in it, which are picked based on user local. If you want the user to decide which language they'd like after install, give them an option. Many apps do this already.
I think you can follow these steps to create the app you'd like to make.
Localize your application. (This tutorial might be useful.)
Add a language parameter to your API calls and return the data based on the language parameter. Thus you won't be displaying a content which is not available in that language.
For your 4th requirement if you'd like to use versioning on each language (I do not know why but if you must) then you can use the language paramter you'll add on API calls. Just create a releation between the languages and the versions you are using then display the views and contents based on the relation.
I'm working with BlackBerry API 7.1 on Eclipse and I want to know if it's possible to add localization for variations of the same language.
I'm working on an app that needs to be localized for 10 countries that speak Spanish, but every country uses different manners of speech.
The problem I'm seeing is that BlackBerry API 7.x's Locale class only has constants for Spain Spanish and Mexican Spanish. Does that mean localization for Spanish speaking countries such as Panama, Argentina, Colombia, etc. get a default localization as if it were Spain Spanish?
Also for this case where multiple variations of the same languages must be dealt with, how should I name the files? I tried adding locale_es-AR.rrc but the - is not admissible on Resource files names, but I don't know if locale_es_AR.rrc is the correct format.
I want to know before adding ten Resource files for these countries that may or may not be usable.
Is it possible what I'm looking for?
What you are trying is correct. Have a look at Localizing Your Files
This file must have the same name as the resource header file,
followed by an underscore (_) and the language code, and then,
optionally, by a single underscore (_) and a country code (for
example, AppName_en_GB.rrc).
I'd like to give users the chance to import data into my app. The app uses core data and my idea would be that the user prepares a text file and send it as email. In the "Open in..." dialog I like my app to be listed.
The file will be a text file but the content must follow certain rules, so that I'm able to extract the data I need to populate core data entities.
Must I define a custom UTI for that?? (I don't want my app listed for every text file)
Yes you can define a UTI, as well as a MIME type for your format. Give it a unique file extension and the fact that's it's encoded in plain text is not important (HTML, XML, etc. all fall into this category).
You don't specify how complex your text format will be, but if it's complex then you might want to consider using a language parser tool to process it, utilizing bison/flex (yacc/lex), or ANTLR.
I am trying to build a web based flash application. I am quite new to flash. I would like to develop it in two forms - demo and paid version. For this application to act as a paid version I need to have some kind of serial key. In order to achieve this I googled and came across something like this
MD5(MD5(thisuri)+thisuri)
I think 'thisuri' points to the current url page but I don't know how to get that url and I don't know whether '+' acts as a character or an operator.
Can you please help me?
It seems that a library exists in AS3.0 : as3corelib
An ActionScript 3 Library that contains a number of classes and utilities for working with ActionScript? 3. These include classes for MD5 and SHA 1 hashing, Image encoders, and JSON serialization as well as general String, Number and Date APIs.
To use it, just download the zip file, decompress it and copy the contents of "src" directory to the root of your project.
Then in your actionscript code, simply do the following :
import com.adobe.crypto.MD5;
var hash:String = MD5.hash(”test”);
source in french
To add to #Julien's recommendation of using as3corelib, you will also need the advice from this post to get the current url: Get Current Browser URL - ActionScript 3
Somehow I think there's a more elegant way to get the url, but I don't remember it.
While this may provide you with some basic check for the paid version, a determined hacker will easily fool this algorithm. For example, I could fool the environment into thinking that its being served from a domain that you've registered as part of the "paid" version. Also, since the client has the flash code, they can decompile the binary and potentially see the algorithm you're using. Depending on what you're offering in the app, this extreme case may or may not be acceptable to you.
Look into more secure authentication mechanisms if you're serious about security.