Author Topic: Translating Menus  (Read 1669 times)

petabyte

  • New to the forum
  • *
  • Posts: 45
Translating Menus
« on: September 03, 2021, 05:34:53 AM »
A while ago I made a proof of concept patch for a Spanish translation of Magic Lantern.
Today I converted it to a module that should work on all versions of ML.

Here it is: https://github.com/petabyt/mlt

Of course, it's very unfinished and unpolished, but I think this could be useful.

Public Volunteer Translation:
French: https://docs.google.com/document/d/14A0eS9CKrAxoJHmEkFWCfA-011OPeWJIFAH7dp3Stx8/edit?usp=sharing
German: https://docs.google.com/document/d/1munmZIPLASBq0aGodO7J9vumgD9TcqnhCKuxYtc72Y8/edit?usp=sharing
Spanish: https://docs.google.com/document/d/1cg7afAO2GxoiJX2iHze2Ntu36CBteEo_miUcJ_kXG7c/edit?usp=sharing

theBilalFakhouri

  • Developer
  • Hero Member
  • *****
  • Posts: 741
Re: Translating Menus
« Reply #1 on: September 03, 2021, 02:29:16 PM »
Cool!

I compiled it in crop_rec_4k branch, enabled it, ML menus were empty, it didn't work properly

I didn't change anything, tested on 700D
700D 1.1.5 | no more ISOless LV err 8 / SDR104 @ 240 MHz - Constant! | Fixed Scrambled LiveView in Higher resolution | Real-Time correct framing in the Way

petabyte

  • New to the forum
  • *
  • Posts: 45
Re: Translating Menus
« Reply #2 on: September 03, 2021, 04:19:15 PM »
I assumed you copied the `mlt_es` file into the ML folder and renamed it as `es`?
Although If the menus were empty, then it's a bug, since it shouldn't do
anything if there is no file. Could you possibly send me a ROM dump for debugging?

theBilalFakhouri

  • Developer
  • Hero Member
  • *****
  • Posts: 741
Re: Translating Menus
« Reply #3 on: September 03, 2021, 07:59:49 PM »
Oh, I didn't copy "mlt_es" to ML folder, after coping it and renaming it to "es" it worked, cool!
Yeah, without "es" in ML folder the menus are empty, I will PM you the ROMs for 700D.

It seems ML can't handle Arabic characters, not sure how to add support for it, maybe we should use another text encoding system/library? (I have no experience with these)
700D 1.1.5 | no more ISOless LV err 8 / SDR104 @ 240 MHz - Constant! | Fixed Scrambled LiveView in Higher resolution | Real-Time correct framing in the Way

names_are_hard

  • Developer
  • Senior
  • *****
  • Posts: 420
  • 200D idiot
Re: Translating Menus
« Reply #4 on: September 03, 2021, 09:57:32 PM »
It's cool seeing the menus in a different language, definitely a good feature to have!  Longer term it might be better to have this in the main code, not a module?  I'm not sure, there are pros and cons.  I suspect it makes most sense that the strings aren't in *any* language in the main code, but instead are referenced by index.  Then you can swap languages in and out easily, by having multiple arrays of strings, one per language, and printing by index.  This is more work but more generic.

Re Arabic characters, kitor did some good work allowing loading fonts from card.  We needed this for modern digic because those cams don't have a bitmap font in rom.  I wrote some scripts that allow converting existing BDF fonts into the Canon format.  So there's a route there that could work.  For the modern cams, they have hardware accelerated font display, using some scalable font format (TTF?  Not sure, some standard, vector format).  These are in roms and likely have many languages (it's what normal Canon menus use), but a) old cams don't have this and b) we don't know how to draw with this yet (looks fairly easy, not tried it).

petabyte

  • New to the forum
  • *
  • Posts: 45
Re: Translating Menus
« Reply #5 on: September 04, 2021, 01:20:39 AM »
> Longer term it might be better to have this in the main code, not a module?
So that would require changing all of the menus? Sounds like a ton of work.

names_are_hard

  • Developer
  • Senior
  • *****
  • Posts: 420
  • 200D idiot
Re: Translating Menus
« Reply #6 on: September 04, 2021, 02:26:32 AM »
It would be a fair amount of work, but localisation tends to be.  With how you have it currently, if anyone changes the english menu text, your match might break, and then it won't display correctly, right?

petabyte

  • New to the forum
  • *
  • Posts: 45
Re: Translating Menus
« Reply #7 on: September 04, 2021, 04:56:32 AM »
Yeah, whenever a string is changed, MLT won't change anything. I've had some ideas
on how I could make it less frequent, but it's definitely an unavoidable issue. Honestly, having
a few untranslated strings here and there doesn't seem like it would be that bad.

Do you have any idea on how often a menu string is changed?

names_are_hard

  • Developer
  • Senior
  • *****
  • Posts: 420
  • 200D idiot
Re: Translating Menus
« Reply #8 on: September 04, 2021, 06:18:01 AM »
Changes are surely very rare :)  I think the way you're doing things will work well in practice.

I do think it would be cleaner if the module only contained the strings for the language, perhaps in an array.  You could have it so every language is a module, including english.  Default build would include english (and I guess language modules would need to be exempt from the "modules don't load if you crashed" logic; or, keep english non-module and it would revert to english if modules didn't load).  Add other modules if you want.  Have a ML menu to swap languages.  Change the main code something like this:

Old code:
Code: [Select]
bmp_printf( FONT_SMALL, 0, y, "Config: %x", (unsigned) global_config );

New equivalent:
Code: [Select]
bmp_printf_localised( FONT_SMALL, 0, y, LOCALISED_CONFIG, (unsigned) global_config );

bmp_printf_localised() looks up the string by the index in the array (LOCALISED_CONFIG would be the index in the array of "Config: %x" in the english array).  That gets passed to bmp_printf().  It's not a hard change, although it is a lot of small changes.

petabyte

  • New to the forum
  • *
  • Posts: 45
Re: Translating Menus
« Reply #9 on: September 25, 2021, 09:26:26 PM »
With a few Python scripts and Google Docs Translate, I was easily able to get several different languages working with MLT.
https://github.com/petabyt/mlt/releases/tag/0.1-more

These were done entirely by Google translate and received hardly any manual review, so feel free to suggest any changes.

Eventually, it may not be a bad idea to pack all languages into a single module. (each language is only 30-40kb)

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 8120
Re: Translating Menus
« Reply #10 on: September 25, 2021, 09:47:49 PM »
Does ML font support german umlauts (ä, ö, ü) and "sharp s" (ß)?

petabyte

  • New to the forum
  • *
  • Posts: 45
Re: Translating Menus
« Reply #11 on: September 25, 2021, 10:04:20 PM »
Not right now, but If I remember correctly, I was able to get some custom Unicode characters working
with https://chdk.setepontos.com/index.php?topic=12813.0

Walter Schulz

  • Contributor
  • Hero Member
  • *****
  • Posts: 8120
Re: Translating Menus
« Reply #12 on: September 25, 2021, 10:13:46 PM »
They are missing right now (replaced by just a, o, u characters) and I'm asking what to do about it:
Nothing?
Replace ä, ö, ü, ß by ae, oe, ue, ss (old ANSI-7 compatible substitution)?
Place "correct" characters which might be not be displayed correctly?

Similar Q for french, spanisch ...

petabyte

  • New to the forum
  • *
  • Posts: 45
Re: Translating Menus
« Reply #13 on: September 26, 2021, 12:17:58 AM »
I had just used the python3 unidecode package to fix the characters.
It looks like they have a reason for this, see https://pypi.org/project/Unidecode/ section "German umlauts are transliterated incorrectly"

For now, I'm think I'm just going to leave them as regular ASCII.
Here's the translated Google Doc: https://docs.google.com/document/d/12txrdFAE401KNcIKUeSYorWbLPK-fVQg9ILj_HRBrME/edit

It might be possible to get my alternative font rendering backend test to work with German characters (see https://github.com/petabyt/mlt/tree/mcufont).
It doesn't seem to show them out of the box, but the Spanish accent characters work:



It could also possibly be used to show Chinese characters too.

petabyte

  • New to the forum
  • *
  • Posts: 45
Re: Translating Menus
« Reply #14 on: September 26, 2021, 12:40:18 AM »
Here are a few German characters working:

petabyte

  • New to the forum
  • *
  • Posts: 45
Re: Translating Menus
« Reply #15 on: September 29, 2021, 01:43:00 AM »
Chinese:

kitor

  • Developer
  • Senior
  • *****
  • Posts: 286
Re: Translating Menus
« Reply #16 on: September 29, 2021, 08:19:10 PM »
It might be possible to get my alternative font rendering backend test to work with German characters (see https://github.com/petabyt/mlt/tree/mcufont).

On our repo I implemented loading bitmap font (Canon format) from card. We had to do it anyway as new generations (Digic 7+, possibly 6 too) moved to TTF, and ML code expects Canon font to be always available.
https://github.com/reticulatedpines/magiclantern_simplified/commit/05a99a7c5f4c0723568382f629bb8b44a89dd7bb
https://github.com/reticulatedpines/magiclantern_simplified/commit/d024a2e23847ef3ee7157f04f43518a73f8990d6

I think this is worth discussing to go in one direction instead of having more font backends - as there are two already (Canon and RBF)

EOS R, 200D, 750D, 50D...

names_are_hard

  • Developer
  • Senior
  • *****
  • Posts: 420
  • 200D idiot
Re: Translating Menus
« Reply #17 on: September 29, 2021, 09:00:12 PM »
Also see these tools I made for converting BDF format fonts to Canon format: https://github.com/reticulatedpines/magiclantern_simplified/tree/dev/contrib/font_tools
There are several freely available BDF fonts with permissive licenses (some including extended Roman and/or non-Roman character sets).

Petabyte, it looks like your mcufont repo has a license violation re the Bitstream fonts as you modify their files and the license says you can't do that if you keep the font names.  Easy enough to fix, change the font names.

petabyte

  • New to the forum
  • *
  • Posts: 45
Re: Translating Menus
« Reply #18 on: September 29, 2021, 10:17:14 PM »
Thanks for letting me know names_are_hard, fixed.

Also, note that the mcufont backend is entirely experimental and disabled by default.
I'm 100% open to removing it in favor of something else.

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3176
Re: Translating Menus
« Reply #19 on: September 30, 2021, 10:52:29 PM »
cool, like that one
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: paypal@g3gg0.de
ONLY donate for things we have done, not for things you expect!