Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add support for UA language translation. #4415

Merged
merged 8 commits into from
Jan 25, 2024
Merged

Conversation

philmoz
Copy link
Collaborator

@philmoz philmoz commented Dec 13, 2023

Initial support for UA.

Not sure what else may be needed for Companion.

edit(pfeerick): To prevent any confusion (as it was not clearly pointed out), the translation included in this PR was not provided by the PR author, but an UA native speaker.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UA fonts are different than RU, they have different subsets of Cyrillic symbols.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate further on this? Any idea what the range is if it's different? Are wrong characters being shown?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the Ukrainian alphabet
Alphabet-01

Copy link

@koliasa koliasa Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kyiv - по цій транслітерації буде коректно?

@olegshevtsov
Copy link

olegshevtsov commented Jan 9, 2024

Hi,

Thanks for your work.
I'm from teams that made translations of ELRS, Betaflight, ESC configurators to Ukrainian. If you need some assistance with honing the Ukrainian version - we'll be happy to contribute.

Last activity in this PR was 3 weeks ago, so let me know if anything is needed for merging the initial version. Thanks.

@pfeerick
Copy link
Member

pfeerick commented Jan 9, 2024

If you can proof the translation that's been provided, that would be a great start. Also, your thoughts on this comment? #4415 (comment)

@olegshevtsov
Copy link

olegshevtsov commented Jan 9, 2024

If you can proof the translation that's been provided, that would be a great start.

How should we do it technically? In this PR or after it's merged?

Also, your thoughts on this comment? #4415

Ukrainian alphabet differs from Russian, I can second it.
Letters that do not exist in Russian:
Ґґ
Єє
Іі
Її
Also the apostrophe is used. https://en.wikipedia.org/wiki/Ukrainian_alphabet
image

@pfeerick
Copy link
Member

pfeerick commented Jan 9, 2024

For you, it's probably easier after this PR is merged (since you'll then be able to do a PR with any changes). At this point, I think it's more just a matter of ensuring there is nothing major that needs changing before merge - like inappropriate words/phrases.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PNGs seem to have only Russian alphabet letters, not the Ukrainian ones. Not sure how it impacts the UI and what's the use of the files.

L'г', L'д', L'е', L'ж', L'з', L'и', L'й',
L'к', L'л', L'м', L'н', L'о', L'п', L'р',
L'с', L'т', L'у', L'ф', L'х', L'ц', L'ч',
L'ш', L'щ', L'ъ', L'ы', L'ь', L'э', L'ю',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the charset looks like is copy-paste from Russian.

  1. It does not have Ukrainian-specific letters Ґ, ґ, Є, є, І, і, Ї, ї and
  2. has some of the extra Russian letters, which are not used in Ukrainian.
    And there is also an apostrophe - ' , which is probably the same as in latin.

https://en.wikipedia.org/wiki/Ukrainian_alphabet

Please correct it.

@olegshevtsov
Copy link

At this point, I think it's more just a matter of ensuring there is nothing major that needs changing before merge - like inappropriate words/phrases.

AFAIKs, the PNGs with font are wrong - they do not have Ukrainian letters - only Russian. And the charset is also wrong / incomplete - misses the Ukrainian letters, has extra Russian letters. Left comments on the code.
image

As for the radio/src/translations/tts_ua.cpp - reviewing translations will take some days. The context is not always clear, so will need to get more context.

@kobakirill
Copy link
Contributor

As for the radio/src/translations/tts_ua.cpp - reviewing translations will take some days. The context is not always clear, so will need to get more context.

You need to draw your own Ukrainian fonts. This is necessary to display the signs on a black-and-white screen.

@olegshevtsov
Copy link

You need to draw your own Ukrainian fonts. This is necessary to display the signs on a black-and-white screen.

@philmoz, I'm not sure I understand the end-to-end flow involving those PNGs - are PNGs generated somehow from the fonts or prepared manually?

@pfeerick
Copy link
Member

pfeerick commented Jan 9, 2024

Have a look at radio/src/fonts/lvgl/make_fonts.sh and more importantly radio/src/fonts/lvgl/get_char_cyrillic.py (which are both part of this PR).

@philmoz
Copy link
Collaborator Author

philmoz commented Jan 9, 2024

You need to draw your own Ukrainian fonts. This is necessary to display the signs on a black-and-white screen.

@philmoz, I'm not sure I understand the end-to-end flow involving those PNGs - are PNGs generated somehow from the fonts or prepared manually?

For colour radios all the font handling is automatic as pfeerick mentioned.

For B&W I believe it has to be done manually. The _utf8_lut array in utf8.cpp needs to be populated with the unicode characters you want to be available for display and then the font_ua_XX.png images need to be edited to contain the corresponding symbols. There are two sets of font images for B&W - one in the 'sqt5' folder and one in the 'std' folder.

@olegshevtsov
Copy link

olegshevtsov commented Jan 9, 2024

Thanks @pfeerick .

  1. I did have a look on get_char_cyrillic.py. It found almost all the alphabet, except Ґ and ґ. It seems that this letter was missing in the radio/src/translations/ua.h. It happens, this is a rarely used letter.

The full alphabet is
АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯабвгґдеєжзиіїйклмнопрстуфхцчшщьюя

The output of python3 get_char_cyrillic.py ../../translations/ua.h is (Ґ and ґ are missing):
АБВГДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯабвгдеєжзиіїйклмнопрстуфхцчшщьюя

  1. Also I did a sanity check for the /radio/src/translations/ua.h.
    #define TR_VOICE_RUSSIAN "Pосійський"
    should be replaced with
    #define TR_VOICE_RUSSIAN "Pосійська"
    to follow the grammar rules.

There are some typos, some items left to be clarified in the context, but it should be safe to commit and do the QA.

  1. As for the fonts in PNG - @philmoz, sorry, I could not get through to make them appear in the repository. I have a string with all letters:
    АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯабвгґдеєжзиіїйклмнопрстуфхцчшщьюя
  • what tools should be used to generate these PNGs?
  • what are the requirements - spacing, padding etc.

PS: Sorry for the noobish questions, this is my first day in EdgeTX repo. Have been a happy user of the English version on my radiomaster.

@pfeerick
Copy link
Member

pfeerick commented Jan 9, 2024

Most likely this file needs extending for the other B&W fonts...

https://github.com/EdgeTX/edgetx/blob/main/radio/util/font2png.py

edit: btw, path to the utf8.cpp file mentioned above is radio/src/gui/common/stdlcd/utf8.cpp

@kobakirill
Copy link
Contributor

АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯабвгґдеєжзиіїйклмнопрстуфхцчшщьюя

your PNGs should be the same as the Ukrainian alphabet.

@kobakirill
Copy link
Contributor

Most likely this file needs extending for the other B&W fonts...

https://github.com/EdgeTX/edgetx/blob/main/radio/util/font2png.py

edit: btw, path to the utf8.cpp file mentioned above is radio/src/gui/common/stdlcd/utf8.cpp

chars_ua = u"""АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯабвгґдеєжзиіїйклмнопрстуфхцчшщьюя"""

@philmoz
Copy link
Collaborator Author

philmoz commented Jan 10, 2024

The output of python3 get_char_cyrillic.py ../../translations/ua.h is (Ґ and ґ are missing): АБВГДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯабвгдеєжзиіїйклмнопрстуфхцчшщьюя

You don't need to worry about this. The python script is extracting just the characters that are actually used in the translation file. So the missing ones are not a problem because they are not currently needed.

@kobakirill
Copy link
Contributor

5. As for the fonts in PNG - @philmoz, sorry, I could not get through to make them appear in the repository. I have a string with all letters:
АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯабвгґдеєжзиіїйклмнопрстуфхцчшщьюя

  • what tools should be used to generate these PNGs?
  • what are the requirements - spacing, padding etc.

Take my PNGs as a sample. Add the necessary characters, remove unnecessary ones. They look good on a black and white screen.

@olegshevtsov
Copy link

Most likely this file needs extending for the other B&W fonts...

https://github.com/EdgeTX/edgetx/blob/main/radio/util/font2png.py

edit: btw, path to the utf8.cpp file mentioned above is radio/src/gui/common/stdlcd/utf8.cpp

I'm not a developer, sorry. I can modify something, but there is little probabilty that it will work fine. Especially with the pieces like font2png.py, where god only knows what parameters should be used: which font, size etc. I tried - and it differs greatly from what @kobakirill has done for Russian.

diff --git a/radio/util/font2png.py b/radio/util/font2png.py
index 9e9139b97..b4ea283a7 100644
--- a/radio/util/font2png.py
+++ b/radio/util/font2png.py
@@ -17,11 +17,12 @@ chars_it = u"""àù"""
chars_pl = u"""ąćęłńóśżźĄĆĘŁŃÓŚŻŹ"""
chars_pt = u"""ÁáÂâÃãÀàÇçÉéÊêÍíÓóÔôÕõÚú"""
chars_ru = u"""АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя"""
+chars_ua = u"""АБВГҐДЕЄЖЗИІЇЙКЛМНОПРСТУФХЦЧШЩЬЮЯабвгґдеєжзиіїйклмнопрстуфхцчшщьюя"""

COUNT_EXTRA_CHARS = 21

chars_extra = u"".join([chr(1+i) for i in range(COUNT_EXTRA_CHARS)])
-chars = chars_en + chars_extra + chars_fr + chars_da + chars_de + chars_cz + chars_es + chars_fi + chars_it + chars_pl + chars_pt + chars_ru
+chars = chars_en + chars_extra + chars_fr + chars_da + chars_de + chars_cz + chars_es + chars_fi + chars_it + chars_pl + chars_pt + chars_ru + chars_ua

def createFontBitmap(filename, fontname, fontsize, fontoffset, foreground, background, coordsfile=True):

font_ua_04x06 png

So it will be definitely tough for me to create my own pull request. But I can help with the language part here, because I know Ukrainian and I'm not afraid to read the code. Hope it clarifies my skill level.

Copy link

@thenester thenester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a long review, but hopefully it would be helpful to improve the overall quality of the translation. Looking forward to see some changes. 😄

radio/src/translations/ua.h Outdated Show resolved Hide resolved
radio/src/translations/ua.h Outdated Show resolved Hide resolved
radio/src/translations/ua.h Outdated Show resolved Hide resolved
radio/src/translations/ua.h Outdated Show resolved Hide resolved
radio/src/translations/ua.h Outdated Show resolved Hide resolved
radio/src/translations/ua.h Outdated Show resolved Hide resolved
radio/src/translations/ua.h Outdated Show resolved Hide resolved
radio/src/translations/ua.h Outdated Show resolved Hide resolved
radio/src/translations/ua.h Outdated Show resolved Hide resolved
radio/src/translations/ua.h Show resolved Hide resolved
@philmoz
Copy link
Collaborator Author

philmoz commented Jan 20, 2024

Do we care that Ukranian is using the country code (UA) instead of the language code (uk)?
Swedish is also the same (SE vs sv).

@pfeerick
Copy link
Member

pfeerick commented Jan 21, 2024

At the present time, the colorlcd translations should be in a somewhat usable state for colorlcd radios, but B&W will not be (until at least the font graphics and mapping is resolved. I would propose at this point to merge this as it is, so there is the start of UA support present in 2.10 and (like with everything else) it will get improved on with adoption and time.

@pfeerick pfeerick merged commit b40c40d into main Jan 25, 2024
47 checks passed
@pfeerick pfeerick deleted the philmoz/ua-language branch January 25, 2024 00:12
@HThuren
Copy link
Contributor

HThuren commented Jan 25, 2024

@pfeerick and @philmoz, are we sure that 'ua' are the right identifyer, in betaflight we use 'uk' and ISO Language Code Table from http://www.lingoes.net/en/translator/langcode.htm say "uk-UA" (compare to Danish 'da' / 'da-DK')

@pfeerick
Copy link
Member

pfeerick commented Jan 25, 2024

For the present time, yes. Only two letters are currently used, and "uk" probably isn't as intelligible. As is alreadly noted in code, we are NOT currently following any of the ISO conventions at present in the references in Companion or firmware. But it is documented as a TODO item ;) In other words, until we move all languages over to something like ISO 3166 (country code) and ISO639 (locale code) pair, this is correct.

@pfeerick pfeerick mentioned this pull request Mar 11, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.