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