Localizable.strings not found at runtime - ios

I develop ios application (iPhone) in MonoTouch(5.2.12)/MonoDevelop(3.0.3.2)
I tried to localize it.
I created localization folders (de.lproj)(Add->New folder) and I placed 'Localizable.strings' file there. This file was added to project (Add->Add files ...).
Localization doesn't work.
I find out that localization files (Localizable.strings) don't locate in runtime place
(/user/jpa/Library/Application Support/iPhone Simulator/5.1/Applications/A99 ...B13/MyApp.app/de.lproj/), even though in MonoDevelop they are.
Why? What is wrong? File is UTF-8 coded. (It doesn't depict with UTF-16)
Thanks.

I believe you'll need to set the build action of your files to "Content" (right click file -> Build Action -> Content).

How do you call your Localized string ? Can you give us a piece of code ?
You don't need to create manually the localization folders, just:
create a Localizable.string file (Right click in project explorer then "New File")
select it
open the Xcode right panel (if not already open)
click on + in the Localization part, and select the language
This method will prevent from manipulation errors because Xcode create the localization folders itself.

Related

Localizing custom SiriKit intent

My Xcode is v10 and I'm developing a custom intent for SiriKit, targeting iOS 12.
In Xcode 10, custom intents are designed in .intentdefinition files, where you can define your own parameters for intent phrases as well as the title of the intent and Siri shortcut for that intent. Building a project with a .intentdefinition file makes Xcode automatically generate an INIntent derived class for that intent.
My issue is that in order to support other languages than English so that the intent's title is show in the system's language in General > Siri & Search when the user is able to manipulate shortcuts for custom intents, I need to provide localized intent title for my .intentdefinition file.
When I try to add another language for my .intentdefinition file in the File Inspector and then build the project I get:
duplicate output file '/Users/.../IntentDefinitionGenerated/Intents/MyCustomIntent.swift' on task: IntentDefinitionCodegen /Users/.../ru.lproj/Intents.intentdefinition
This is likely happening because Xcode sees multiple .intentdefinition files in .lproj folders and tries to generate a same named class for each of them.
How do I localize my .intentdefinition file for iOS 12?
Go to intentdefinition file -> File Inspector -> Select Localize -> Now select current language for your intentdefinition file.
This will convert your existing intentdefinition file for current language.
Now again select the same intentdefinitionfile, add other language -> it will create a new Intents.strings file where you can customize the text for other locales.
I had the same issue as #desmond-hume. In my case, I have an old xcode project that already contained some localizations before "Base" was available. The initial .intentdefinition file must be added as the Base localization. From there, further localization can be added and Xcode will add only a .strings file for each localization.
Without a base localization, Xcode adds a new .intentdefinition for each localization which causes the "multiple commands produce...." error.
You can add a Base localization under the main project settings via a checkbox.
Some old projects (like mine) may also run into this issue:
iOS - Using Base localization pane is always empty
It looks like you've already localized your Intent Definition file (since Xcode has put it into a ru.lproj folder) so the problem might be that you've two copies of the file in the "Compile Sources" build phase.
Go here:
Project -> App target -> Build Phases -> Compile Sources
and look for duplicate entries. If you find a duplicate, delete one of the copies
You can also try Editor > Validate Settings… to find duplicates
You can also try cleaning the build
I've recently Localised the intents for my App, however after the original localisation, I added another Intent.
In Xcode 10.2.1 at least that I've checked, there is an "Export for Localization" option when you select the top level of your project.
It will ask you to save the output.
When you investigate your output, you should see an .xcloc folder for EACH of the languages you support.
Dig down to the .xliff under "Localized Contents" and open it.
There you will find your treasure trove of the items and you're looking for and you're looking for items that don't have a 'target'
The engineers at Apple at dub dub showed me this, however I personally wasn't happy of this process, as you have to edit it, and then re-import it (assuming you send off your files to a translator and get an .xliff back.
The annoyance though with Intents is the fact that it uses arbitrary IDs and not something legible
I haven't found an easier way (yet) to locate the missing translations.
Hope this helps!
you must be Project->info checked "Use Base Internationalization"
Next use the top answer method to create

Cannot localize my app (adding a localization language shows no files and adds nothing)

Basically I can't add Localizations from the project > info > Localizations section.
When i try to do so, i can see the languages and select the one I want. But when the "Choose files and reference language..." screen appears it is completely empty. When i press finish nothing happens as well.
My goal is to localize the app name, so i have to add the InfoPlist.strings files to the languages I need.
If i try just selecting the file and pressing the localize button i get a prompt asking me to select the language, if i try any of the languages shown there i get this message error:
“Info.plist” couldn’t be moved to “ja.lproj” because either the former
doesn't exist, or the folder containing the latter doesn't exist.
I even tried manually adding the .lproj folders and adding the files there but the app name doesn't change. I suspect that it is because the project is configured to look for those in a different place.
This project was originally created with cocos2dx so it came with many things preconfigured, that was a long time ago with an old version of cocos2dx, so i suppose the folder structure has something to do. Still i don't know where to fix to at least be able to add more localizations.
The solution I found was to first create the "InfoPlist.strings" manually as a file inside the project directory. Then add the file from xcode. Then clicked on localization and select at least 1 language. Then i could add/remove localizations from my project settings.

iOS - error during archiving noting UAPushLocalization.bundle/en.lproj/Localizable.strings

I created a new set of controllers and when I tried to archive the new code, I got this error which happened when the archiving was going over those controllers:
error: open /Users/owner12/Library/Developer/Xcode/DerivedData/Marketing-eusiyfrkjsbjfxdgpauubwhvpazb/Build/Intermediates/ArchiveIntermediates/Marketing/InstallationBuildProductsLocation/Applications/Marketing.app/UAPushLocalization.bundle/en.lproj/Localizable.strings: No such file or directory
I understand that it is talking about the push-enabling library. And something about some localization setting.
But I have no idea how to fix this.
Would anyone be able to suggest how to fix this?
And here is the screen shot of this reference highlighted in red in the Build Phases --> Copy Bundle Resources list.
Thanks,
Alex
Xcode has some weird issues with localization from time to time. I would recommend you to copy all the text in the EN localization file (expand the localization strings file and select the english one "en"). Paste it somewhere, right click the file, show in finder, delete, select the localizations file, uncheck localization for english, clean your project, select the localization file, check the english one (a new file will be created) and paste your strings here.
Also make sure there are no typos in it.

I deleted the Localizations in Xcode, then I cannot add any Localizations back

I deleted the Localizations of the project from the project's info by mistake. Both the storyboard and the related language were removed.
I got back the storyboard from previous file but when I want to add a new Localization, a window popped out and asked me to "Choose files and reference language to create English localization" and there is no resource file at all.
How can I add back the localizations?
Adding back a localization
When you delete your localizations sometimes you can get that situation where you can't add back any localizations in Xcode. Go to the command-line and create a ISO 639-1 two-letter language abbreviation folder with the lproj extension somewhere within your project.
Create an empty language folder
For example:
${SRCROOT}/Resources/Translations/nb.lproj
or
${SRCROOT}/Resources/Translations/en.lproj
Re-add language files to project
In the folder create an empty file called Localizable.strings and add this file to your project. Don't add the .lproj folder, just the contents. Then when you go back into the project file you will see the language under localizations. Now when you have added this, you should see the localization in your project.
No checkbox
If the added file, like a storyboard, doesn't have a checkbox next to it indicating that is part of that language localization you might need to round trip them through another language. To do this add a new language in the project. It should prompt you to copy the existing localized files over to the new language. Then delete the broken localization and re-add it.
My Example
As a specific example, I added the storyboard in the nb.lproj directory to the project. The Norwegian Bokmål appears in the project, but the checkbox for the language in the storyboard inspector won't let me add it. I created nb_NO in the project and it prompted me to copy over the storyboard. Then the storyboard had that checkbox checked. I deleted the 'nb' localization and re-added it. Now everything was the way I wanted it.
I had to solve same problem, and found one solution:
You need to find in finder your *.xcodeproj file and open it as container (ctrl+click on it and you will see it in context menu)
Here you can see project.pbxproj file, open it in Xcode. Its large (but still readable file).
(it will be better to make some copy on save spot, before you start)
Now its the task to add the missing language to this file, and its done.(U can try it on other project with localizations).
There is paragraph you need to add. Search in this file for this /* End PBXSourcesBuildPhase section */(its paragraph right before localization paragraph which is missing) and add something like this after:
/* Begin PBXVariantGroup section */
27548D921611B0BE008EA1CD /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
27548D941611B0BE008EA1CD /* en */,
);
name = Localizable.strings;
path = ../Code;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
You have to do some changes first. Look at the long number 27548D921611B0BE008EA1CD, its ID of the localization file (or some xib file, or other localizable file...), if you dont have any in the procject, just add some Localizable.string file to the project, reopen(or refresh) this project.pbxpro, and find this Localizable.string you should find something like this:
275490591611B0BE008EA1CD /* Localizable.strings in Resources */
and this is it what you need to replace in localization paragraph
also you need to do right settings on path parametr and sourceTree. This twos are readable in fileinspector in xcode.
The "sourceTree" param is Location - mostly its relative to group so sourceTree = "<group>";
The path is path relative from the group to the file (if you dont know, try to make some localization files in different project and look at project.pbxpro, what all this works)
After this you can save project.pbxpro, and you should see in xcode info section "en" localization and you can add more localizations and all other localization stuff.
In xcode 6, do the following:
With the command line, create the following directory/file structure somewhere outside your project directory:
/en.lproj/InfoPlist.strings
/en.lproj/Localizable.strings
In Xcode, open your project and choose File>Add Files to ProjectName to add the recently created en.lproj directory.
After that, you will see English in the Localizations list.
This is an old topic, but after having this issue, and then trying the solution (and having it not work exactly), I thought I'd give details on what DID work.
Like the original poster, I accidentally deleted all of my localizations and was given no obvious recourse in Xcode-- in the project settings under Info it simply said 'this project has not been localized', and when I clicked on the plus button beneath, a blank list of resource files was presented.
I followed #Cameron's guide but found that language folders with Localizable.strings files were already present in Finder, but weren't being acknowledged by Xcode. I couldn't decide how to proceed, but I happened to see an unrelated comment about adding files to Xcode, so I tried adding the existing en.lproj folder and its Localizable.strings file.
This worked, and the listing for English as the development language appeared under Info as well.
Hopefully this will help anyone who experiences the same problem!
Simply create a Folder "Base.lproj" in finder and paste the Xib you want to localize inside it, and add this folder to your project. Now you can able to add other languages without issue.
I've followed a similar approach of #user2070775 reply.
Firstyl when you delete Storyboard and Launchscreen to use your own creation or code programmatically, on Localization you might get similar following empty screen.
Then firstly you should know the language code for example to use French localization its fr etc
With project folder in the Project Navigator you must add New Group -> {LANGUAGE_CODE}.lproj. And then you should add New File -> Strings File -> Localizable.strings. In the #user2070775 answer, also InfoPlist.strings file has added so I added too for now.
In the Localizable.strings file you can add <KEY> = <VALUE> pairs for string to localizated.
Our pair is "this-is-key" = "and-this-is-value-for-spesific-language-on-localizable-string"; for now.
HINT: In key-value pair, when I did not put the semicolon, the XCode
gives error for this situation.
Until now, the following project scheme, must the result of you have.
Additionally, when you looked at the Project -> Info -> Localizations the French or etc. language must be added like in the following image.
TESTING
Basically you can get the results of the what've you done
The remaining part can be set from the Simulator. You must change the simulator language, for this answer the correct one is French.
Go to Settings -> General -> Language & Region -> French and run the project again.

Moving localization folders in Xcode 4

I've recently upgraded from Xcode 3 to Xcode 4.2, and migrated an existing iOS apps to use this new version. This app is localized, and I now want to add another language.
Under Xcode 4, when I add the new localization, it creates the country specific folder in the project root. For example:
/fr.lproj
All of my prior language folders are in a Resources sub-folder, however. Such as:
/Resources/de.lproj
/Resources/en.lproj
For the life of me I cannot figure out how to get Xcode 4 to move the new language folder to Resources. There is no GUI option I can find. If I move the physical folder using Finder, Xcode just changes the reference to red, but gives me no option to fix it.
Can anyone help?
UPDATE:
Here are a few screenshots demonstrating the problem (using Chinese this time):
The file listing:
The identity section for that file. Note that I can't change it:
Found the solution. It's not pretty, but it works.
Here's what I did:
View the contents of the .xcodeproj folder in Finder
Edit the project.pbxproj file
Search for .lproj within the file
Change the path = section to include the Resources part of the path.
Save, then restart Xcode
This smoothed everything over, and allowed the Localization to reside in the Resources subdirectory.
Here's a way how to solve it w/o editing .pbxproj file (Xcode 4.6.3):
select localization parent file (Localizable.strings)
Utility pane > Identity and Type > under Location (Relative to Group) choose path icon and set required new location for localization files
Finder > move all your en.lproj, fr.lproj, etc subfolders to that chosen folder
UPD: doesn't work in Xcode 8 :(
This way works on Xcode 5.1 also (Greek example):
Create Resources/el.lproj folder within Localizable.strings file in Finder
Open your project file in Xcode and right-click on Resource folder
Click on "Add File to..." context menu item
Select Localizable.strings file from Resources/el.lproj folder -> OK.
Greek Localizable.strings automatically will be added to Localizable.strings files.
You can use the same way to add localization for xib files.
The file structure on disk is mostly irrelevant in Xcode. Just move the directory in Finder, then in Xcode you can either: (a) remove the fr.lproj directory and re-add it, or (b) select the red entry, open the right-hand (properties) panel, and near the top you should see the path. Change the path to the new location and it'll go back to black.

Resources