Skip to content

Instantly share code, notes, and snippets.

@wahyusa
Last active June 21, 2022 08:47
Show Gist options
  • Save wahyusa/037c9565843c5bfbc1a2bdad56c9439f to your computer and use it in GitHub Desktop.
Save wahyusa/037c9565843c5bfbc1a2bdad56c9439f to your computer and use it in GitHub Desktop.
How to add specific locale/timezone/language in ubuntu through terminal and use it on python 2022

How to add specific locale/timezone/language in ubuntu through terminal and use it on python 2022

Original source 😁👌

Add another locale if not exist (linux)

Add other locale in docker (linux)

Just a another little notes.... and I didn't completed this yet sorry... but I think 2 link above will help you.

TLDR

Instead of installing new locale in your machine, you can just use pytz module for use in python Simple right ? XD

In case you are just using locale module from python you may already define your own locale code or something like id_ID or id_ID.UTC8 or maybe ar_AR etc But the code send error that Timezone format is not valid something like that, then it means you need to install new locale pack based on language you needed. So that you can get specific locale datetime with day name in your language by installing new locale pack!

IDK if it was a great choice or not, what if you running that in VM or Cloud ?? your VM may need to configure that locale again and install again bla bla So I found pytz it looks awesome and I can use it to show multiple timezone. Again, IDK what is the best way to do this but for now I prefer pytz cuz it was easier..

https://pypi.org/project/pytz/

python print day name in specifig language Sunday => Ahad => Minggu => etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment