DEV Community

Pramoth Suwanpech
Pramoth Suwanpech

Posted on

1

ติดตั้ง thai locale ใน CenOS/Alma/Rocky linux ใน docker

วันนี้ลองเล่น almalinux 9.4 image แล้วมันไม่ได้มี locale thai มาให้ จะติดตั้งก็ง่ายๆด้วยคำสั่ง localectl เพราะว่าอยู่ใน container จึง research หาสักพักเลย จึงจะ note ไว้หน่อยละกัน

almalinux image ไม่ได้ใส่ avialable locale มาให้เรามันมีแค่ POSIX locale ดังนั้นเราต้องติดตั้งเพิ่ม เราเช็คได้ว่ามันมี avialable locale อะไรมาให้บ้างด้วย locale -a
ซึ่งจะมีแค่

[root@d121e84764c6 /]# locale -a
C
C.utf8
Enter fullscreen mode Exit fullscreen mode

locale file ของ avialable locale Redhat จะอยู่ที่ และ /usr/share/i18n/locales
file chracter map จะอยู่ที่ /usr/share/i18n/charmaps ถ้าเรา ls ดูน่าจะยังไม่มีเลย
การติดตั้งก็หา package มาลงตามนี้
yum -y install glibc-locale-source glibc-langpack-en glibc-langpack-th ซึ่งภาษาไทยก็จะอยู่ใน package glibc-langpack-th

หลังจากติดตั้งแล้ว เราลอง list avialable locale อีกที

[root@13c0780e7ad2 /]# locale -a
...
...
th_TH
th_TH.utf8
Enter fullscreen mode Exit fullscreen mode

จากนั้นเราก็ใช้ได้เลย โดย set environmant var LANG
export LANG=th_TH
แล้วเช็ค locale ของ current terminal เราด้วย locale จะได้ตามนี้

[root@13c0780e7ad2 /]# locale
LANG=th_TH.utf8
LC_CTYPE="th_TH.utf8"
LC_NUMERIC="th_TH.utf8"
LC_TIME="th_TH.utf8"
LC_COLLATE="th_TH.utf8"
LC_MONETARY="th_TH.utf8"
LC_MESSAGES="th_TH.utf8"
LC_PAPER="th_TH.utf8"
LC_NAME="th_TH.utf8"
LC_ADDRESS="th_TH.utf8"
LC_TELEPHONE="th_TH.utf8"
LC_MEASUREMENT="th_TH.utf8"
LC_IDENTIFICATION="th_TH.utf8"
LC_ALL=
Enter fullscreen mode Exit fullscreen mode

เป็นอันว่าเรียบร้อย ที่เหลือก็ไปเซ็ตให้มันใช้ได้กับทุกๆ user ในไฟล์ /etc/locale.conf หรือ per user ในไฟล์ $HOME/.i18n

note locale package ของฝั่ง ubuntu จะเป็น language-pack-XX

อ้างอิง

https://stackoverflow.com/questions/58304278/how-to-fix-character-map-file-utf-8-not-found

https://access.redhat.com/solutions/974273

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay