Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localizing the Edit menu and other standard menus

I'm trying to translate my Mac app into a few different languages. There are a large number of menu items, particularly in the Edit menu, that are provided by OS X and work automatically. I assumed these items would be translated automatically as well, but they don't seem to be. As you can see in the screenshot below, I'm getting a mix of translated and untranslated items.

The Edit menu, partially localized

Strangely, the same menu items are translated when they appear in a contextual menu, for example in an NSTextView. In this case everything is translated automatically, aside from the two Services at the bottom.

A contextual menu, automatically translated

So I'm very confused: do I really have to translate the Edit menu myself? I obviously want my translations to match Apple's, so I'd be doing an awful lot of copy and pasting. Or is there some secret to getting the localization to kick in? My app requires 10.7 or later, so if there's anything newish that makes this easier, that shouldn't be a problem.

Addendum: Assuming there is no easier way to do this, is there at least an easy way to copy the text of Apple's translations so I can paste them into my app? I was thinking I could just open up a NIB from one of their apps, but they're all compiled, and can't be opened in Xcode. I can open them in a text editor, but trying to find the appropriate strings this way doesn't seem any faster than just retyping everything.

like image 317
robotspacer Avatar asked Aug 02 '12 19:08

robotspacer


People also ask

Where is a menu bar?

The menu bar is the part of a browser or application window, typically at the top left side, that houses drop-down menus that allow the user to interact with the content or application in various ways.


3 Answers

Update:

Thanks to this helpful post by Douglas Hill I've learned there is actually a proper solution to this. Apple maintains a list of Glossaries that include strings for a huge number of uses. They're designed for a command line tool named AppleGlot, but they can also be opened in a text editor. Apple's Internationalization page includes links to these tools. Localizing Strings Files Using AppleGlot includes some information on how to use AppleGlot—though currently the app's installer has an expired certificate, and it doesn't appear to be compatible with Catalina regardless. Douglas Hill's post offers some alternative ideas for how to automate the translation process.


Original Answer:

From what I can tell, there really is no easy way to do this. For Japanese in particular, I ended up using a process like this:

  1. In Finder, right-click on an existing app, like TextEdit, and choose "Show Package Contents"

  2. Inside the package, go to Contents/Resources and you'll see the localization folders like en.lproj and Japanese.lproj

  3. Inside those folders, you'll see the NIB files. Using a plain text edit (like BBEdit), open the main NIB file for your main language and the language you want translations for. In many cases the files you want will be named MainMenu.nib. With TextEdit, the files are named Edit.nib. The files are XML, so they're clearly structured, but there's a lot of stuff you don't care about. Having the two files open makes it easier.

  4. In the English file, you can search for something like "Check Document Now". Directly below that is the keyboard shortcut (;) and the method the menu item calls (checkSpelling:). Now you can search the Japanese file for checkSpelling and the translation you need is right above it. It sounds tedious, but I've found it pretty quick for the most part, especially since you rarely need to type everything out fully to find what you need. Many of the method names are obvious too—like cut: paste: copy: and so on, so as you go you may be able to skip checking the English file first.

  5. Menu items that are submenus are a bit trickier, since the method will just be submenuAction:. You can use the surrounding XML to help verify you're looking at the same thing in both NIBs, or you can check in the app itself to make sure you're looking at the right text. Google Translate was also helpful when I wanted to make sure I copied the right thing. You might even try using Google Translate first, and just verify that it matches what Apple uses.

Obviously you need to either be very careful, or have someone who speaks the language verify everything works as expected. It'd be better to just have a translator do all the work. In my case, I've had people volunteer to do translations, and all the text unique to my app is already translated. I didn't want to bother them with the tedious work of translating a bunch of text someone else has already translated.

like image 174
robotspacer Avatar answered Dec 22 '22 00:12

robotspacer


Localized Nibs contains MainMenu.nib files, with the menubars pre-localized into various languages. All items are connected to the proper actions, and several additional resources are included (such as flag graphics, ISO language tables, and more).

localize-mainmenu - Command line tool that localizes the common main menu items of an OS X app automatically.

like image 43
catlan Avatar answered Dec 22 '22 00:12

catlan


I found Martin Stemmel's git project useful (FYI: I have connection to the author). It is free and you can simply browse the various language files for the standard main menu strings u need or use the project.

https://github.com/martnst/localize-mainmenu

like image 30
Cliff Ribaudo Avatar answered Dec 21 '22 22:12

Cliff Ribaudo