UIWebView localication - ios

I'm developing multi languages application and intent to have DONE button localized. This button is appear in UIWebView when user clicked on dropdown ("select" tag) with multiselect:
By default, this is always in English. However, if you set CFBundleAllowMixedLocalizations to YES in .plist file, you will be able to get it in current SYSTEM language:
Here, DONE is written in Chinese, when text in select in Arabic. It is because current system languages (i.e. set in Settings) is Chinese, but inside app I selected Arabic so app is using Arabic bundle with Arabic strings file.
I wonder, is any possibility to localize "DONE" button to current Application's language, but not system language?

Don't use "Application's language". Simply use the system language, like all other applications do.
I'm sure it's possible to somehow achieve it, but you're simply taking the wrong approach to localization.

Related

Development Language IT on Xcode

Hello everyone I wanted to have information ...
I changed the development language on Xcode EN -> IT
Now I wanted to know if these changes will remain even when I publish the app on the app store or if they remain only during development
My app is for Italy only and I wanted to know if I can avoid entering Locale(identifier: "it") for each date display, now that I have set the development language to Italian.
You will want to go to File > New File > Strings File, name it Localizable.strings, this is important.
Open the attribute inspector. Click Localize..., select your language.
In your file, for each piece of text you want to show in your app, come up with an identifier/key for it, then write as follows:
"welcome_message" = "Welcome to my app!"; // This would be in your English file.
Then do the same thing for each language you want to support, but just change the phrase itself in each file, and keep the same key/identifier.
Then when you want to use that phrase in your app, replace whichever String with NSLocalizedString("welcome_message", comment: "")
No need to set Locale(identifier:String) in your files. The app will look for the device's set language and use the corresponding Localizable.strings file.

How can we localize a wallet pass's strip.png properly?

I am trying to localize a pass and save it in the iOS wallet.
The problem is that while the text on the back of the pass properly localizes, the strip.png image does not.
The strip.png image will be the image that was originally exported from my app.
So if my app was currently using the Spanish language, the Spanish strip.png would be exported. If my language was set to English the English strip.png would be exported.
However, once it lives in the wallet app the strip.png no longer changes. If the strip.png was in English and I switch the language to Spanish, the strip.png would still persist while the text on the back of the pass would change to Spanish as expected.
My .pkpass object contains two folders: en.lproj and es.lproj.
They both have their own localized version of strip.png and pass.strings file.
What am I doing wrong?
If localizing a strip.png is not supported then what are some other alternatives?
You have come across a "feature" of Wallet, designed to save space on a user's device. The rationale behind this feature is that users rarely change their base locale.
Once a .pkpass bundle has been installed on a device, all of the unnecessary image assets are dropped.
If, as it sounds, your pass is installed with the correct locale image, then your bundle is correct. Unfortunately this means that to demo the locale functionality, you will need to delete and then reinstall the pass with a new language setting.

Localization not working on Xcode

I can't get my app to work with localization.
I have created a Localizable.strings file and ticked the languages that I am localizing. (For now I have base, english and spanish.)
Localized storyboard with three languages.
In Project settings > Info I checked Use Base internationalization and all languages are correctly added. (Moreover, beside the language it shows 2 Files Localized, which I guess they must be the storyboard and .strings file.
I am using this example for testing:
self.loginLabel.text = NSLocalizedString(#"login", #"Login text info");
This is how the Localizable.strings (Base) file is looking like:
"login" = "Log in";
However, it is not working and instead it is showing login. Have I forgotten a key step?
BTW: I have tried already changing the login text just it case something was overriding the label.
Those are the steps indeed, I don't think you've left anything out. I usually set the comment to nil instead of another NSString though - not sure if that makes a difference.
However, rather than in only base, make sure you're adding the same line also to the English and Spanish files (obviously translated as appropriate).
Next, for the language to show up, set the device to said language. Close your app and start it again. Strings should now show up in the other language.
Note that the Simulator often has trouble with new translations, especially when they've been added to an already deployed app. In that case, remove the app from the Simulator, click on Product - Clean, and re-deploy.
In my case, it didn't work because the UILabel text was set as "Attributed" instead of "Plain" in the Attributes Inspector.
Localization with a .strings file doesn't seem to work on Attributed strings.
I even had a storyboard with mixed Plain and Attributed string labels, and the localization only worked on the Plain ones.
For anyone having a similar issue in the future:
Check if your *.strings file has any non-printed characters.
I used JavaScript for a simple task and didn't realize it included some whitespace characters.
An easy way to check is to put the translation at the top of the file and see if it works. If it does, there might be some whitespace characters. The next steps are... binary search and remove the whitespace characters.

change langue on the fly IOS

I would like to make a button in the app , i want my app support Chinese and English. lot of the sample on the web require restart the app to take effect. is there any way to change the language in the App without restart the App ?
Ive done something like this in my application.
saved my button or item text in different language other that english in NSUserDefaults
then in application load it check "Lang" keny value in NSUserDefaults.
if other than "eng" , it load that language.
if u put button or list with ability to select and change lang key in NSUserDefaults then the
only think u should do is to change all item text base on list or array u made in ur
application per language.

Localization for a very simple app.. How to connect a button?

I have a very simple app which only contains a PickerView, UILocalNotification, UIAlertview and less than 8 views. What I want is:
I have a main view which contains two buttons one says English and the other says French.
What in my mind is:
When the user hits English it'll take him to the Project I have right now,
However, when the User hits French it'll take him to a duplicated views that I'd simply and manually change and translate it's labels into French.
** Now my question is ** how do I translate the PickerView, LocalNotification and the AlertView? and how to connect the French button to these translations?
From what I've googled and read here in SO is that I can get the strings out and list them into Localizable.strings but I still don't know how to make my french button ask for these strings? Also, is there an easier and simpler way? any idea?
Thanks,
Kindly try this for doing localization
http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial
For buttons use something like this
[self.yourButton setTitle:NSLocalizedString(#"YOUR_KEY", #"Comment") forState:UIControlStateNormal];
Do not duplicate your views and view controller just for the sake of localization, considering that for both languages have the same layout and everything only thing that would change is the language. So add English strings and French strings to your project and use NSLocalizedString to get these values.
Note:NSLocalizedString works with device language only so if you want to change the app's language manually try this. I have used AMLocalizedString in many of my projects and they work fine.
Hi as you want to make it localized only at App basis not at device basis hence NSLocalisedString will not work you have to manage it so you have to take two different files and you have to fetch the string value on the basis of selected language. In similar manner as LocalisedString works as in localization there are multiple .strings file created for languages and it works in a way to select default language of the device and shows the text from the localised file.

Resources