Custom iOS Popover for Print Options - ios

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

Related

IOS 8 NSLocationAlwaysUsageDescription custom translation

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.

iOS: Is it possible to override the locale set on the phone and make it use a strings for a different locale?

In iOS, is it possible to override the locale currently set on the phone and make it use a strings for a different locale in my app?
In short: Yes.
The NSLocalizedString is a macro, which you can replace with your own macro and do the language loading yourself. This might require setting most of the strings in code though and you will not be able to use them in Storyboards.
However, changing the locale manually in NSUserDefaults works if you want to change the locale.
The answers below explain more on this topic:
Custom NSLocalizedString?
change locale programmatically
Change app language programmatically
iOS: How to change app language programmatically WITHOUT restarting the app?

How I can show english text in arabic

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.

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.

UIWebView localication

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.

Resources