I understood that I can have localized NSLocationAlwaysUsageDescription text using standard iOS localization mechanism.
Since we are using our custom dynamic localisation mechanism I wonder if there is another way to translate that string.
I thought of editing application info.plist file on app start, but it seems to be read only.
Can I change this value from withing the app?
There is a way. Add a new Strings file called "InfoPlist". Then localize it using a Localize button in attributes inspector and add localizations to the InfoPlist's keys. To localize CLLocation premission's description add in every version proper key and loacalised value.
//English file
"NSLocationAlwaysUsageDescription" = "English description";
_
//Polish file
"NSLocationAlwaysUsageDescription" = "Polski opis";
There's no way to use a custom localisation system with the info.plist strings.
That part of your app will have to use iOS's default localisation mechanism.
This is how to localise the location request description with iOS's built in strings file localisation system.
// English.strings file
"NSLocationAlwaysUsageDescription" = "English description";
// AnotherLanguage.strings
"NSLocationAlwaysUsageDescription" = "ajbdknfuied wibnrf";
EDIT: At everyone down voting me. The question asked about using a custom "custom localisation system". They explicitly said they did not want to use the built in localisation system, but instead their own custom one. That is why I said it was impossible.
Localising NSLocationAlwaysUsageDescription is completely possible. Using your own custom localisation system to do it is not.
I tried using the answers above, but had no luck until I used the information in this much more helpful thread.
Related
I'm getting ready to have my app localized into other languages.
I'm using NSLocalizedStringWithDefaultValue to provide default English text within code, although I guess none of that maybe relevant.
I'm not adding localized text directly to nib or storyboards, everything is in my strings file.
I'll probably end up uploading those to a localization site.
So I'd like to use fastlane deliver to upload screenshots and meta data.
However I'd like to find a method where I can pickup values from my strings files.
So I guess my question is, how can I get my strings value into my deliver text file?
Or is there a better / quicker approach I should use?
We're currently at the stage of looking at localising our app in to multiple languages now that the general concepts of the app have been decided. This is something I want to ensure is done correct from the start to lower the risk of headaches in the future.
The app targets iOS 7 and above, uses storyboards, and is written in Swift.
Storyboards
When working with a storyboard (or a xib), what's the best way to mark a UI element as "not to be translated"? For example, I have a placeholder string for a user's display name (Display Name), which will be replaced by a users display name at run time. This display name will not be localised, but neither should the string "Display Name". Is there a method of not having a UI element's value automatically put in to the strings file? If not, is going in to that file and manually removing strings I don't want localising a sustainable option?
Strings In Code
I'm using the Swift function NSLocalizedString with the key and comment parameters. Some places I've seen say to set the key to be a unique id based on the context (e.g., intro.login-button-text), while others seem to just put the full string in the default language (e.g., Login). I like the idea of the unique ids for the key, but would this not go against the idea of the "base" language?
Exporting
Xcode 6's "Export For Localization" option seems very useful for getting the correct format of file to be sent to translators. However, as mentioned previously, placeholder text does not need to be translated. Should these placeholders be removed from the exported xliff or the strings file prior to export?
Looking for the the same questions myself. Hope this will help you and others. Also I would recommend to have some kind of tool to organize the xliff/string files
Storyboards:
I've seen developers putting non translating texts in storyboard with extra parentheses. i.e. {Display name}.
By using this you can see by the translation itself if it needs to be translated or not. We use oneskyapp.com and can select to hide those translations and they will be hidden for each import of that key.
Strings in Code
By following this thread they suggest to use keywords.
Best practice for key values in translation files
Exporting
I cannot find a way to have some translations automatically removed when exporting. Off course you can put the views which has dynamic fields in different XIB/storyboards and decide not to translate those.
Again a tool like onskyapp.com can help you with this.
Formats
As of context with the field is important and a translation can be different when it is followed by i.e. a users name I would go for "%1$# is online!"
I have English string like "my name is abc". I want show it in Arabic I don't want to put Arabic strings in project .I want to use on NSString or any available functions in Objective c.
If you want to localize your application you must enable it in the application and provide a Localizable.strings which contains all the translations.
you can use it like this:
someTextField.text= NSLocalizedString(#"The text you need to translate", #"comment_optional");
then in your Localizable.strings you should have:
"The text you need to translate" = "the translation you need";
reference for using NSlocalizedString (https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html)
It is not possible. You will have to put language resources inside the project to support multiple language.
I think what you want is translate English to Arabic and not localisation (correctly pointed out by Rajneesh071 as well).
If you are looking for an offline solution, you are out of luck as it is not possible. For online solution, you can make use of Google translate API. It returns JSON response which can be parsed and displayed in your application.
Refer this tutorial for more information on how to use this api in iOS.
Hope that helps!
You can use Localization in your application. You must define another string file which consist arabic language
This link you can take as a reference.
I am trying to create a multi-language Application where I can print a document.
When Print button is pressed it shows a standard iOS popover with print options.
But its in English and not in the language of the device
I Localized Strings for my application. Also the other parts are working fine. But I am not able to find the exact place where set the labels in the Print Options.
This is what I used to call the popover for Print Options
[printController presentFromBarButtonItem:sender animated:animated completionHandler:completionHandler];
What would be the method to convert the labels on this popover to custom language i.e. Device language.
An example on the same will really be appreciated. Thank You.
I suggest you go through Apple's Localisation/Internationalisation guide for multilanguage support.
https://developer.apple.com/internationalization/
The way for you is to use NSLocalizedString in place of NSStrings.
You need to Localize your application.
Create .strings files for the supported languages
Add the localized string as a key value pair in the .strings file
Use the key to retrieve the supported language string (Device language)
You can use this code for retrieving the localized string:
NSString *localizedString = NSLocalizedString(#"key", #"");
Tutorials:
Localize iOS app
NSLocalized String
You can set the language in the application's main method. Look at this answer Using different language for system views than the current device language
I wrote a game with cocos2d and translated all the image and text in the
game in two different language.
When the app launches, I load different resource according to the locale of
the device and this worked all OK.
Then when I upload this app for review, I first named it say "test".
Then in the localization part I add a language "Japanese".
But I found that in the "Japanese meta data part", I can edit a lot of
things except the "app name" which is "test". But I want my app to show
different names according to the locale of the device also.
Can somebody tell me how to get this work? Thanks in advance...
You can create a file called InfoPlist.strings in each of your language specific directories, and set a language specific value for CFBundleDisplayName.