XCode: Show all localized files for one language (IOS project) - iphone

I have been searching XCode and Google all over, but I just can't find out how to do it:
I am using Base localization and it shows 4 Files Localized for English. I have no idea why it's 4 and I would like to find out why.
But how? How can I get a list of all localized files (and where these files are located)?
Is this such an uncommon task that I can't find any answer to it? Or is it that obvious and I am just unable to find it?
I realized that when I am trying to add another language (like Japanase), I will see there are 4x InfoPlist.strings-files for English and 1x file for Base Localization (Storyboard), but I still don't know why and where are these files and how to remove them.
Checking the en.lproj Folder, there is only 1 InfoPlist.strings-file. Why XCode is telling me that I have 4 of them?

There is a way to delete the localized files. If you are using version control, you can make sure your work is committed and your tree is clean. Then when you delete the localized files, you can just check the status of your tree and see what files they were, and recover them a figure out what you need to do from there.
I agree that it is a pretty terrible developer experience. Just add it to the list of ways in which mobile developers are abused.

Xcode is deriving this information from your project file. So if you can't deduce it by looking at your lproj folder, you can open up pbxproj file (under your .xcodeproj folder) and search for the locale in there.

Just had the same issue. Here is a really easy way to get a list of all localized files, by going through the motions of adding a new language (and cancelling):
Project -> Localizations
Hit the plus button to add a new language.
Select any language.
The "Choose files and reference language to create ... localization" dialogue will appear. This is a list of all localized files.
Hit cancel (don't add the new language).

use this answer manual language selection in an iOS-App (iPhone and iPad)
You can set any language you want, remember "Localizable.strings" for containing language text

The easiest way is to open een finder screen in the root of your project. After that enter en.lproj (or your main language) in the search bar.
Select to only search in the folder
Now you have a list with all the files which are localized.

You can check your files selecting them in Project Navigator and then looking at File Inspector on the right of Xcode.
Here, if your file is localized, you can see what languages are present and select/deselect them.
You can also use Finder: go to your project folder, there there are folders named like ja.lproj or it.lproj (the actual name changes as per Xcode version). In these folders you'll find all the files that are localized for that language (e.g. in ja.lproj you'll see al file localized in Japanese).

I was wondering the same myself. I had not started the localization process and Xcode was already telling me I had "2 Files Localized".
You might want to check the targets in your project. I had one InfoPlist.strings file for my main target and a second InfoPlist.strings file for my unit test target.
By trying to add a new localization, a confirmation screen shows up with a table listing all Resource Files and a dropdown for each Reference Language associated with those Resource Files.
Resource File != Localized File.
Reference Language = Localized File.
For every language you see in the Reference Language drop-down the "Files Localized" counter goes up by one.
In my case this confirmation screen had shown two identical entries corresponding to the InfoPlit.strings resource files in each target with English being the only language referenced for each, making it "2 Files Localized".
Funny thing about all this is that the "Resource Files" don't technically exist in the file system, only the localized files do in those .lproj folders.
"Resource Files", as far as I can tell, are Xcode nonsense.

Related

Localizing iphone app html files and strange xcode 4.2 warnings

I've got an App that I am trying to localize for several languages. I'm doing most of the localization through .strings files, but for the larger help files, I need localized versions of html files.
I've read Apple's documentation as well as doing many searches on Google, and I think I am doing things correctly.
In my xcode project directory, I have an "en.lproj" and a "ja.lproj" (Japanese). I put versions of my HTML help file in each directory, and I import these into my Resources group in xcode. After doing so, the files seem to show up correctly. I see a "help.html" file under Resources, and it is a "group" and if I look inside it I see:
help.html (english)
help.html (japanese)
When I build my App, my App seems to correctly contain the two versions of the files under their appropriate .lproj directories, and everything is working correctly when I run the App (I see English documentation when settings are English, and Japanese when settings are Japanese).
However, when I build my project, I get annoying warnings from xcode 4.2:
Warning: Multiple build commands for output file .../ja.lproj/StartQuizController.html
Warning: Multiple build commands for output file .../en.lproj/StartQuizController.html
From what I understand, these "multiple build command" messages occur when there are conflicting filenames that are being added to your App. However, since these files are localized and exist in their own subdirectories, there is no real conflict.
Am I doing something wrong, or are the warnings a bug in xcode 4.2?
Thanks,
Ron
I think you can prevent these warnings if you do it the Xcode way.
Xcode uses only one copy command to copy the localized files, you have probably two separate commands.
You could try to delete the files form the "copy bundle resources" build phase first.
Delete the copy command for the localized files and add a new one. If Xcode treats your localized files right it should show a single file instead of a file for each localization in the "Choose items to add"-Picker.
If that doesn't work just remove them completely and add the physical files again.
Backup all your html files. Then delete them from the project (both logical and physical).
Add the English version of the file to Xcode, let Xcode copy it to your directory.
Select file in left sidebar
Open first tab of the right sidebar
add localizations by using the + button in the localization section
either replace the content of the file trough Xcode or use Finder to replace the localized versions.
I´m trying to localize my project as well. I always add a in-App user´s manual in a html file wich gets loaded on a UIWebView.
I haven´t done it yet, but what I´m going to do is to create different files for each language, say for example:
info_en.html // for english
info_es.html // for spanish
info_ca.html // for catalan
then when the webView gets loaded, instead of loading the #"info_en.html" file, I will load the NSLocalizedString(#"info", nil); Then, in each localized string file, the name for the html file will match the language.
I believe this should help but, again, I haven´t tried myself yet.

Creating Localization Files for iOS

I would like to localize one of my apps. But I just CANNOT seem to figure it out. I have tried to read apple's docs, and I have looked at a bunch of tutorials that I found by searching. I understand how to change all my strings to NSLocalizedStrings, and how to edit those localized files one there created, but my problem is I can't figure out how to create those directories in the first place.
How do you make those folders en.lproj and a spanish one. Also, how do you make the two string files that go inside them.
Step by step help would be greatly appreciated, or a link to a detailed tutorial on this part.
Thanks in advance.
Note: I've made countless attempts and an simply stuck.
you are nearly done with doing NSLocalizedStrings. You open up terminal.app and change the dir to your project by changing dir. Type in cd and drop in your project folder. Then tipe in: genstrings ./Classes/*.mthis will create a file with all strings you entered. Look in your project folder for Localizable.strings and drag it into Xcode project. Uncheck the box that says "copy into destination group..." and change the text encoding to UTF-16! Then open the info window for that file and check "Make file localizable", switch to general tab and enter for ex: fr for the new localization and click add. Now you can change the localization to french, where it says fr (or whatever you have)
When selecting a file, in the Utility sidebar you will see the localization panel.
There you can add languages.
Note that in Xcode 4.4 and up you have to go to the Project Info and add all the languages there, you can't add languages from any file info

How to localize special ressource types like sounds, images, movies, html files and so on?

I know I can use NSLocalizeableString() for strings. But how about about other kinds of resources? I guess there are some kind of language folders where I put that into? Is there an good blog article that describes this?
Right click on any file and choose Get Info. In the General Tab of the InfoView hit the Make File Localizable button, and add a localization. Xcode will copy this file to a location-specific folder in your project.
I use Finder to copy my language specific files into those folders.

How do I properly add existing source code files to my Xcode project?

I'm new to iPhone development and I'm still getting familiar with the Mac dev environment, including Xcode. I want to add some 3rd party code to my iPhone project, but when I add the "existing files" to my Xcode project, I'm presented with a dialog box that has far too many options that I don't understand and, as such, my project isn't working. When I #import headerfilename.h, I get a build error that reads headerfilename.h: No such file or directory.
alt text http://joecrotchett.com/images/misc/fileadd.jpg
Can anyone explain to me what all these options mean or give me a link to some documentation that can? I'm having a hard time finding anything in Apple's docs.
Which options do I want to choose to add existing source code files to my Xcode project? I should note that the source code files that I'm trying to add are located in my project/Classes/frameworkname/ directory.
After they're added, do I need to reference this new code directory in my project settings anywhere (i.e. some kind of header file directory variable)?
Thanks so much!
Update: I found the following answers/responses on the apple dev forums that were very useful and helped me fix my issue...
To make it simple :
- if you do not check the copy option, the file stay where it is.
- if you check it, it is copied in your project folders In the first case
(what it seems you are doing) you need
to tell the compiler that the header
files are in another directory :
- project info -> build -> search paths -> User Header Search Path : add
the directory from where you took the
header file Hope this will help
You have discovered the most confusing
dialog box that ever came out of
Cupertino. Six years of Xcode, and
this thing still is partly a mystery
to me. To even get that far, I had to
make many test projects to try and
reverse-engineer what this thing does.
The "Copy" box means that it will copy
the files as they are right now, into
the project. If this box is not
checked, then it just references those
files during a build and copies them
as they are at THAT time. For source
code, you want the Copy box checked.
The "relative to" is a total mystery
to me and I can't help you with that.
I usually leave it however it is
already set. Does it mean relative to
where they are on disk, or the
arrangement in Xcode, or in the
bundle? Who knows. The last 2 radio
buttons SEEM to mean that it will
either re-create the folder structure
of the folder you are adding, or just
put "fake" folders in Xcode that point
to the real folders. This is probably
your problem - you are adding source
code that is not all at the top level,
and when it goes to find it, it does
not re-create the hierarchy. Others
can supply a better way, hopefully,
but what I would do is put all of the
source in one folder and add that,
using the Copy box. Then in Xcode you
can make whatever bogus folders you
want and put the source file names in
those fake folders.
This is from the Xcode user guide:
"The project navigator shows projects, groups, folders, and files:
The project or projects in your workspace window are the highest level
of the hierarchy in the project navigator. Open the project’s
disclosure triangle to see the groups, folders, and files in the
project. Select the project to display the project editor, where you
can view and edit project and target settings.
A group appears in the project navigator as a yellow folder icon. The
group does not represent a folder on disk. Although you can organize
your project in Xcode to reflect the organization of files on disk,
moving files into and out of groups does not affect the content of the
folders on disk, and moving files on disk into and out of folders does
not affect the content of the groups in the project navigator.
A folder is a reference to a folder on disk and appears in the project
navigator as a blue folder icon. The contents of the folder in the
project navigator reflect the contents of the folder on disk. It’s
important to note, however, that the files that appear in a folder
icon in the project navigator are not part of your project unless you
have added them to the project explicitly (in which case they appear
directly under the project or in a group, as well as in the folder).
You can view and edit the files in a folder, but to move files in and
out of the folder you must use the Finder.
A file in the project navigator is a reference to a file on disk."
I think usually the default option is the best one. If you want to add into some group, you can tick on the "Copy Item to Destination group"
You don't have to change any project settings after adding
And if you want to add the whole framework code, please choose add existing framework
Copy items into destination group's
folder (if needed)
Well, only if you want it to copy the files. If you are happy with their existing location and don't want it to copy them, don't select it (that's what I do).
Reference Type:
A total mystery to me
Text Encoding
Self explanatory
Recursively create groups for any
added folders Create Folder References
for any added folders
Leave this as the default and then organize the folders in your Xcode project any way you want.
Add to targets
If you add an additional target to your project, e.g. for iPhone vs. iPad versions, then not noticing that it has by default added the files to just one of them (at random?) can cause headaches.
Also, make sure you add the new header directory to your search paths in Project Settings > Build > Search paths. I think that's what's causing your problem.
Hope this helps, I remember how confusing this was to me at first.
If you want to add an Framwork Bundle, just add is as one. Add -> Existing Frameworks

How do I localize multiple files at once in Xcode?

In the process of localizing my app, I have about 50 resources (mostly xibs) that need to be localized. I know how to add a localization for each file, but it's a pretty time consuming process to open the info panel and add the localization for each file.
Is there any way to select multiple files and add a localization to each of them in one shot?
Edit to add: Is this a place where AppleGlot or iLocalize can help? I haven't yet looked at those tools.
Just create a directory for the language you are localizing for if it isn't already there (e.g. "en.lproj") and copy all the files there. Then go into xcode and add the newly copied files to your project.
Have you tried using ibtool? This tool, which runs from the Terminal, can list the classes or objects in a nib files and can also dump the localizable strings into a plist.
I haven't tried this tool though, but you can find more info by typing "man ibtool" in the Terminal.
Selecting multiple files in the left/navigator pane and then adding localizations via the right/utility pane is supposed to work, but doesn't. I filed bug #9276560 against Xcode 4.0.1.
If you need to support a lot of languages, this can help:
Click on file #n
Add one localization
Repeat steps 1 and 2 for all files
Click on the project in the left/navigator section
In the project info pane, add localizations
What that does is add every previously localized file to the new language(s). You'll still have to add 50 files separately, but at least you won't have to perform 50 operations times the number of languages. In my case, that saved me several hundred steps.
The answer is in the other post here
In essence, you have to create xx.lproj directories for all your languages.
Then copy all localized files to their respective directories.
Now your lproj dirs should have the files with the same name (but with different localized contents).
Then you add all files from all dirs into Xcode.
Xcode will assign them to appropriate locales based on the lproj dirs where they reside.