I have my infoPlist.strings with my localizable strings. I want to add on my info.plist the resource I added. How do I accomplish that?
On Infoplist.strings:
"NSAppleMusicUsageDescription" = "My description";
On Info.plist:
NSPhotoLibraryUsageDescription - $(NSPhotoLibraryUsageDescription)
NSAppleMusicUsageDescription - $(NSAppleMusicUsageDescription)
Or changing $ for # is not working either...
Thank you
STEP-I : On Info.plist put the default value
STEP-II : Create Infoplist.strings file and localize it to all supported languages
STEP-III : On each Infoplist.strings file put localized values to every key you want to localize its messages
The application uses the Info.plist key-value as a default value if it didn't find a specific language file. so, you can put English value in the Info.plist file and translate other languages in specific localizable file
Related
I'm new to IOS and currently I'm working on Localization of Displaying Apps icon.
and I made InfoPlist.strings
and then I put the text for like this in my InfoPlist.strings(MyLanguage) file
"CFBundleDisplayName" = "sometext sometext andlasttext ";
and it literally shows every text, include   on iphone emulators home screen.
and of course either
"CFBundleDisplayName" = "sometext sometext andlasttext";
is also not working! could you help me?
This solution works for me before iOS11 consider space as double space.
But from iOS 11 Apple has stopped truncating for longer app names. I thing if app name count is greater then 12 to 14, the spaces will be removed. Otherwise, they'll still exist.
= 2 spaces
Localizing your app display name is actually a very simple task, so let’s just get right into it.
Set up Localization
First, make sure you set up localization for another language (Note, this is not all that is required to completely localize an app, just the display name). Select your project in the project navigator, go to Localizations, then select a language to localize your display name.
Create a Strings File
Next, you have to create a Strings file that will contain the localized name to be used in your project. Go to File > New > File, select your OS target, go to Resources, and select the Strings file template.
Select the template, enter InfoPlist into the name field, and create the file.
Adding Localized Strings
Once you have created your strings file, open it and select all of the languages you would like to localize for in the inspector. In your base language file, add the following:
/* Localized Bundle Display Name */
"CFBundleDisplayName" = "Your_Localized_Name_In_Native_Language";
Then, enter the same in every other language file, swapping in your translated name in the place of your native name as so:
/* Localized Bundle Display Name */
"CFBundleDisplayName" = "Localized_Name_In_Other_Language";
When you are done, each file should look like the following:
Add Localization Keys to Info.plist
The last thing you have to do is add the necessary keys to your Info.plist file to enable your app to read and swap in your localized display name when appropriate. The first key you will add is the “bundle display name” key, it will look like so:
Bundle display name = $(PRODUCT_NAME)
You also have to add the “application has localized display name” key and set it to yes, which will look like the following:
Application has localized display name = YES
These keys in Info.plist will look like the following:
Thats all there is to it! Your app name will now be displayed in all languages that you localize to.
In my framework app, I have some localization files added and have a method to get
localised strings as follow
-(NSString *)getCurrentLocale{
return NSLocalizedString(#"mykey", nil);
}
and I have installed this pod into one demo app, and trying to get the locale but it always returns the key, (it returns 'mykey')
I have double checked the format and name (Localizable.strings) within the string files
all files has proper format
but I do have locale strings as values in my Localizable.strings
ex: "mykey" = "ar_SA";
any Idea where I am going wrong?
Usually, this happens when you don't have the Localizable.strings file in the appropriate language folder (e.g. de.lproj). Also, ensure you haven't put your Localizable.strings file in the Base.lproj folder, as the same problem will occur.
To summarize, make sure your project Localizations have their Localizable.strings files in their respective language folders to provide the correct translations.
Finally, if the above are true (and this may be obvious), the device must have its locale set to actually pull strings from a given language.
Reference: Internationalization and Localization Guide
As many people don't know, the way to localize an application name on iOS and OSX is to add an InfoPlist.strings file to the bundle and localize that file. People mix this file with the Info.Plist file. Localization is not done into the Info.plist, is done in the InfoPlist.strings file.
Said that, I have created this file with two keys: CFBundleDisplayName and CFBundleName, as I always do. This works wonderfully and you can define different names for your app in different localizations. This file works seamlessly. You have to do nothing, just add the file to the project and localize it.
InfoPlist.strings is a strings file like this:
"CFBundleDisplayName" = "My Localized App Name";
"CFBundleName" = "My Localized App Name";
For this project in particular I have also to read the value of CFBundleDisplayName at run time.
I have tried to use this code:
NSString *appName = [[NSBundle mainBundle] localizedStringForKey:#"CFBundleDisplayName" value:nil table:#"InfoPlist"];
to read the CFBundleDisplayName key but the value I get back is CFBundleDisplayName. In other words, I provide the key and receive the key back, not the value. I should receive My Localized App Name.
What am I missing?
I did this exactly in Swift, and it works as expected.
let appname = NSBundle.mainBundle().localizedStringForKey("CFBundleDisplayName", value: nil, table: "InfoPlist")
but, if I delete de localisation string from the corresponding InfoPlist.strings file, it returns "CFBundleDisplayName".
So, check that you are not missing something in your .strings files
After trying several possibilities..
The BUG was "A second copy of InfoPlist.strings inside the project"
I have an application and I want to add a mix of static and dynamic app shortcut items. Localizing for dynamic items is pretty straightforward, using NSLocalizedString, but not so much with the items in your info.plist. I already have an InfoPlist.strings file for localizing the name of my application, but I am less sure about how static UIApplicationShortcutItems would work since these items do not have a unique key.
How do you localize static UIApplicationShortcutItems?
Turns out that the app will search the InfoPlist.strings file for a corresponding key matching the value in the Info.plist. That might sound a little confusing, so here's an example:
For the UIApplicationShortcutItemTitle key in the info.plist, add a value of, say, ADD_ITEM_SHORTCUT_TITLE:
<key>UIApplicationShortcutItemTitle</key>
<string>ADD_ITEM_SHORTCUT_TITLE</string>
This value will then need a corresponding entry in your InfoPlist.strings file:
ADD_ITEM_SHORTCUT_TITLE = "Add Item";
Add one new string file and save it with name "InfoPlist.strings"
Enable Localization for this file, and add string with title like below explanation.
Now Open your info.plist file and add title like below.
After adding a few Localizations:
and localized the (AppName)-info.plist file:
and checked Bundle Resources (also tried to remove Go-info.plist from the Copy Resources Bundle list:
and the file property:
Xcode (4.6.3) give an error:
error: could not read data from '.../Go/Go/Go-Info.plist': The file
“Go-Info.plist” couldn’t be opened because there is no such file.
It looks like Xcode ignores the localization folder in the path. It tried to find the info.plist as:
.../Go/Go/Go-Info.plist
instead of:
.../Go/Go/(Localization)/Go-Info.plist
How can I fix it?
I think Info.plist can not be localized. If you want to localize your application Name, you should localize the InfoPlist.strings file and use those keys :
"CFBundleDisplayName" = "AppName";
"CFBundleName" = "AppName";
Step by step localized Info.plist:
Find in the x-code the folder Resources (is placed in root)
Select the folder Resources
Then press the main menu File->New->File...
Select in section "Resource" Strings File and press Next
Then in Save As field write InfoPlist ONLY ("I" capital and "P" capital)
Then press Create
Then select the file InfoPlist.strings that created in Resources folder and press in the right menu the button "Localize"
Then you Select the Project from the Project Navigator and select the The project from project list
In the info tab at the bottom you can as many as language you want (There is in section Localizations)
The language you can see in Resources Folder
To localize the values ("key") from info.plist file you can open with a text editor and get all the keys you want to localize
You write any key as the example in any InfoPlist.strings like the above example
"NSLocationAlwaysAndWhenInUseUsageDescription"="blabla";
"NSLocationAlwaysUsageDescription"="blabla2";
That's all work and you have localize your info.plist file!