Blackymas / NSPanel_HA_Blueprint

This allows you to configure your complete NSPanel via Blueprint with UI and without changing anything in the code
1.42k stars 259 forks source link

`Enhancement` Adding Thai localization and fixing broken Thai language. #2331

Open Aekung opened 3 days ago

Aekung commented 3 days ago

Enhancement Summary

Enhancement Adding Thai localization and fixing broken Thai language.

Detailed Description

  1. How can I help in localizing this project for Thai language? I can help translating all the words from English to Thai (one by one) if it means to get my native language supported by the project.

  2. Currently, Thai characters are displayable since it's also included in full charset list. However, it's not being display in a correct way and it's impossible to read. I believe it's due to the letter combination we have in our language and it much like Korean or Chinese where we mix the character up for words with upper and lower letter for vowels and intonations.

Based on the hmi/dev/ui/fonts/CJK/Full Charset.txt, we currently have

"กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำ฻฼฽฾฿เแโใไๅๆ๏๐๑๒๓๔๕๖๗๘๙",

which covers all of Thai letters, vowels, intonation marks and numbers. However, when we write word in Thai, we combine these characters in a weird way and not just by ordering the letter from front to back to form a word. This is why the word appear on the display in a weird way when it has an upper or lower letter. For example, "ข ำ" is displayed instead of "ขำ", which is the correct way to write the word.

I think the problem could be both an unsupported Thai character font is being used in the project or the the space between the letter is too much that it causes the letter break.

I tried to look for the font_id or anything that I can use to tweak in the yaml of ESPhome in order to change for to Thai supported Google font but I can't seem to find that in both substitutions: area and anywhere in the esphome/nspanel_esphome_core.yaml. As I'm a newbie in ESPHome, can you please guide me what should I do in order to change the displayed font to the fully supported Thai character from Google Font or how can I make this project 100% compatible with Thai language?

This project is such a great project. Thank you very much for making NSPanel usable for real.

Really looking forward to your reply.

Additional Context

IMG_5333 Picture showing how the Thai characters are currently displaying on the NSPanel with the project.

edwardtfn commented 3 days ago

Do you mind splitting those in two different issues (maybe just add a new issue for the display issue)? As those have different complexity levels, it would probably be easier to handle those individually.

edwardtfn commented 3 days ago

For the first request, could you please help the the translation of the following strings (just the part on the right of :)?

        en:     # English
          bytes_per_char: 1
          weekdays:
            mon: Monday
            tue: Tuesday
            wed: Wednesday
            thu: Thursday
            fri: Friday
            sat: Saturday
            sun: Sunday
          weekdays_short:
            mon: Mon
            tue: Tue
            wed: Wed
            thu: Thu
            fri: Fri
            sat: Sat
            sun: Sun
          months:
            jan: January
            feb: February
            mar: March
            apr: April
            may: May
            jun: June
            jul: July
            aug: August
            sep: September
            oct: October
            nov: November
            dec: December
          months_short:
            jan: Jan
            feb: Feb
            mar: Mar
            apr: Apr
            may: May
            jun: Jun
            jul: Jul
            aug: Aug
            sep: Sep
            oct: Oct
            nov: Nov
            dec: Dec
          relative_day:
            today: Today
            tomorrow: Tomorrow
            in_2_days: In 2 days
            in_3_days: In 3 days
            in_4_days: In 4 days
          climate:
            states:
              "on": "on"
              "off": "off"
            heat: heat
          please_confirm: Please confirm
          unavailable: Unavailable
          unknown: Unknown
          no_name: No name
          alarm:
            home: Home
            away: Away
            night: Night
            vacation: Holiday
            bypass: Custom bypass
            disarm: Disarm
          settings:
            reboot: Reboot
            sleep: Sleep mode
            brightness: Brightness
            bright: Bright
            dimming: Dimming
            dim: Dim
          meridiem:
            am: AM
            pm: PM

As a reference, you can take a look at other translations here: https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/e146b1f35dfe38cd8d2da90828695f8a37865b0c/nspanel_blueprint.yaml#L4855

Thanks a lot for your support with this. 😃 I will do my best to have these strings included in the next release.

Aekung commented 3 days ago

Do you mind splitting those in two different issues (maybe just add a new issue for the display issue)? As those have different complexity levels, it would probably be easier to handle those individually.

Will do. Let me finish the translation and I will open another issue for the display.

Thank you.

Aekung commented 3 days ago

For the first request, could you please help the the translation of the following strings (just the part on the right of :)?

I will post the translation for you within an hour.

Thank you.

Aekung commented 3 days ago
        th:     # Thai
          bytes_per_char: 3
          weekdays:
            mon: จันทร์
            tue: อังคาร
            wed: พุธ
            thu: พฤหัสบดี
            fri: ศุกร์
            sat: เสาร์
            sun: อาทิตย์
          weekdays_short:
            mon: จ
            tue: อ
            wed: พ
            thu: พฤ
            fri: ศ
            sat: ส
            sun: อา
          months:
            jan: มกราคม
            feb: กุมภาพันธ์
            mar: มีนาคม
            apr: เมษายน
            may: พฤษภาคม
            jun: มิถุนายน
            jul: กรกฎาคม
            aug: สิงหาคม
            sep: กันยายน
            oct: ตุลาคม
            nov: พฤศจิกายน
            dec: ธันวาคม
          months_short:
            jan: ม.ค.
            feb: ก.พ.
            mar: มี.ค.
            apr: เม.ย.
            may: พ.ค.
            jun: มิ.ย.
            jul: ก.ค.
            aug: ส.ค.
            sep: ก.ย.
            oct: ต.ค.
            nov: พ.ย.
            dec: ธ.ค.
          relative_day:
            today: วันนี้
            tomorrow: พรุ่งนี้
            in_2_days: มะรืนนี้
            in_3_days: ในอีก 3 วัน
            in_4_days: ในอีก 4 วัน
          climate:
            states:
              "on": "เปิด"
              "off": "ปิด"
            heat: ความร้อน
          please_confirm: กรุณายืนยัน
          unavailable: ไม่ปรากฏ
          unknown: ไม่ทราบสถานะ
          no_name: ไม่มีชื่อ
          alarm:
            home: อยู่บ้าน
            away: ไม่อยู่บ้าน
            night: เข้านอน
            vacation: วันหยุด
            bypass: ข้อยกเว้น
            disarm: ปิดระบบ
          settings:
            reboot: รีบูธ
            sleep: โหมดพักหน้าจอ
            brightness: ความสว่าง
            bright: แสง
            dimming: ลดแสง
            dim: หรี่
          meridiem:
            am: AM
            pm: PM

Hope this helps. Really hope to get to see Thai localization in the project soon. Please do not hesitate to let me know if I can still be any help in order to localize this project to Thai language.

Thank you in advance.

edwardtfn commented 3 days ago

This was solved in DEV and will be included in the next release.

Aekung commented 2 days ago

This was solved in DEV and will be included in the next release.

I changed the ref to DEV branch and re-flashed my NSPanel successfully but I couldn't find 'Thai' in the localization of Blueprint Setting Page. Is there anything I must do in order to activate and test these Thai language and make sure everything is working great before the 'main' version update?

Thank you and looking forward to hearing from you.

edwardtfn commented 2 days ago

You have to update the Blueprint also and this is a manual process:

TFT also must be update, but this is easy, as you can just press the TFT button to update as you do now.

But please be aware the version on dev is quite broken, so be prepared to return to main after your tests. 😉

Aekung commented 2 days ago

Thanks for the link.

I'll do some testing tonight and will give you feedbacks then swap back to the main branch.

Aekung commented 2 days ago

Tested and the only page I could get to interact with is the front page (Home Screen), I can see the day, which is 'อาทิตย์' just fine but for the date and month, it only shows 20 (which is date) without following by the month. When switching back to English, it shows a complete Sunday, 20/10 though. I think it's because of the max char limit in that text area.

For some reason, clicking on other pages will just return back to Home or not going anywhere. Because of this, I can't check whether other pages on the panel could display everything correctly.

I'm switching back to main now but do let me know if you want me to test anything indev branch.

edwardtfn commented 2 days ago

Ok, I will increase length in some of those common fields...

edwardtfn commented 2 days ago

About not opening the other pages is an issue I'm working on right now and is not related to the language you selected.

edwardtfn commented 1 day ago

I've just tried and the pages are opening... It's slow, but it is opening. Are you sure you cannot open the pages? Could you please share your ESPHome logs?

Aekung commented 1 day ago

I've just tried and the pages are opening... It's slow, but it is opening. Are you sure you cannot open the pages? Could you please share your ESPHome logs?

When I tried navigating to any pages, the screen flickered and came back to home page instantly. However, it did manage to show a climate page in a blink but it was too fast that I couldn't notice anything apart from the temperature bar.

Will re-flash back to dev branch to get the ESPHome logs.

Aekung commented 3 hours ago

Re-flashed back to dev branch with dev branch blueprint and latest version of TFT from dev branch. The result is still the same. I can't navigate to any pages as it will just send me back to home in a blink. I also notice the Red HA icon but when I trigger stuff from the physical relay switch (which is bind to turn on/off the fan without wiring anything for real), it could turn on and turn off the fan as normal. I assume that the blueprint links to the Panel just fine (since it also shows Thai language on the date) but I don't know why the HA icon is still showing red.

I should also mention that I'm only using bluetooth proxy addon with the panel as well.

Please kindly find the log enclosed along. I tried to subtract anything that is not relating to the NSPanel so it's easy for you to diagnose.

Thank you.

esphome-nspanel-ha-blueprint.log

edwardtfn commented 2 hours ago

Your logs shows the tentative of a service call providing the parameter id, but this parameter is not in use by v4.4.0dev1. Are you sure you are using the latest Blueprint?

Without that, it will flag as missing the blueprint (the reason for the red icon) and this will prevent opening most of the other pages.