Nagwa-Limited-Community / Glyphs-MATH-Plugin

11 stars 1 forks source link

Localize the plug-in #4

Closed khaledhosny closed 8 months ago

khaledhosny commented 2 years ago

Provide at least Arabic localization in addition to English.

schriftgestalt commented 8 months ago

There are two ways to do it. Put the localized strings into the code:

title = Glyphs.localize({
    'en': "Show MATH Italic Correction",
    'de': "Zeige MATH Italic Verbindung"
})
menuItem = self.newMenuItem_(title, self.toggleShowIC_)

That is fine for a smaller number of strings and keys.

Or use Localizable.strings files and NSBundle to pick the right string.

NSLocalizedString("Show MATH Italic Correction", "")

(or make a shortcut like NSLoc()) A Localizable.stringsfile is put in a folderen.lproj`de.lproj and ar.lproj (check the Glyphs bundle for available languages).

"Show MATH Italic Correction" = "Zeige MATH Italic Verbindung";

That setup is a bit more involved but easier to maintain. And has less clutter in the code.

What way do you prefer. I can help set it up.

khaledhosny commented 8 months ago

Thanks Georg, I appreciate your help. The second approach seems cleaner, so I’d go with that.

florianpircher commented 8 months ago

You can have a look at one of my plugins for the .strings table files and the use of those strings in code.

My code is in Objective-C, but the idea is the same with Python and pyobjc.

schriftgestalt commented 8 months ago

I just pushed a german localization. That includes the setup and some tooling to keep it updated.

khaledhosny commented 8 months ago

Thanks George, that is wonderful. I’ll see if I can add Arabic localization.