supervisor用法
python paramiko实现ssh远程登录

gettext国际化用法示例

妙音 posted @ 2015年9月09日 16:36 in python with tags 国际化 , 5452 阅读
  • 安装gettext
sudo yum install gettext
  • gettext工具
gettext: 进行translate。
 
xgettext: 从程序中抽取调用gettext进行本地化的字符串,生成一份.po结尾的配置文件。
 
msgfmt: 将配置好的本地化配置文件进行转换成gettext使用的格式。
  • 准备demo.py
#encoding=utf-8
import gettext

# demo对应mo文件名,locale为locale目录地址,zh_CN为locale目录下目录名
zh = gettext.translation("demo", "locale", languages=["zh_CN"])
# 激活_()
zh.install(True)
print _("hello world")
  • 生成po文件
 
从程序文件中抽取,使用gettext的字符串,生成po文件
xgettext -L python -o zh_CN.po demo.py
  • 编辑po文件
...
#修改编码为utf-8
"Content-Type: text/plain; charset=utf-8\n"
...

#加上翻译
#: demo.py:6
msgid "hello world"
msgstr "你好,世界"
  • 创建locale目录
mkdir -p locale/zh_CN/LC_MESSAGES
 
* 编译po文件
msgfmt -o ~/locale/zh_CN/LC_MESSAGES/demo.mo zh_CN.po
  • 查看结果
➜  ~  python demo.py
你好,世界
 
Avatar_small
f88tw 说:
2020年10月09日 15:02

敬启者:个人小网站希望大家多多支持 感谢您对我们热心的支持 f88tw┃华歌尔┃I appreciate your kind assistance. f88tw|墓园|捡骨流程|捡骨费用|捡骨时间|禁忌|捡骨颜色|捡骨师|新竹|时间|台北|桃园|苗栗|头份|火化|晋塔|安葬|法事|捡骨|看日子|墓穴|墓园|坟墓|看日子|乞丐|http://mypaper.pchome.com.tw/f88tw

Avatar_small
토토사이트 说:
2020年11月19日 16:54

If more people that write articles involved themselves with writing great content like you, more readers would be interested in their writings. I have learned too many things from your article. <a href="https://ttattack.com">토토사이트</a>

Avatar_small
sagame66 说:
2020年11月21日 17:09

Believe it or not, it is the type of information I’ve long been trying to find. It matches to my requirements a lot. Thank you for writing this information. sagame66

Avatar_small
helphub 说:
2020年11月23日 06:17

Whether it is popular games like Baccarat, Slots, Blackjack, Roulette and Dragon Tiger etc. สล็อตออนไลน์

Avatar_small
buy soma 500 说:
2020年11月23日 21:33

Hi there, I found your blog via Google while searching for such kinda informative post and your post looks very interesting for me. okdermo skincare

Avatar_small
Floor level sofa 说:
2020年11月24日 17:28

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Floor level sofa

Avatar_small
best over the counte 说:
2020年11月26日 14:41

Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks best over the counter weight loss pills

Avatar_small
buy soma 500 说:
2020年11月26日 15:18

The first phase the preparation should, theoretically, be uninfluenced by the intended intensity and duration of the sound which is subsequently produced. In fact, however, so quickly are the three phases accomplished that the pianist rarely has capacity to think, in performance, of each phase separately. Gulf Coast Western Reviews

Avatar_small
GSM Solutions 说:
2020年11月26日 19:38

Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! GSM Solutions

Avatar_small
thc vape juice 说:
2020年11月26日 20:54

Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also thc vape juice

Avatar_small
berita terkini 说:
2020年11月28日 15:22

A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. berita terkini

Avatar_small
The MoonExports 说:
2020年11月28日 17:38

Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. The MoonExports

Avatar_small
no excuses runner 说:
2020年11月28日 21:10

Regular visits listed here are the easiest method to appreciate your energy, which is why why I am going to the website everyday, searching for new, interesting info. Many, thank you monsta x merch

Avatar_small
no excuses runner 说:
2020年11月29日 15:49

This is my first time i visit here. I found such a substantial number of interesting stuff in your blog especially its examination. Really its inconceivable article. Keep it up. ateez merch

Avatar_small
no excuses runner 说:
2020年11月29日 16:31

Your post is very helpful to get some effective tips to reduce weight properly. You have shared various nice photos of the same. I would like to thank you for sharing these tips. Surely I will try this at home. Keep updating more simple tips like this.  หนังออนไลน์

Avatar_small
no excuses runner 说:
2020年11月29日 17:00

Extremely intriguing online journal. A lot of web journals I see nowadays don't generally give anything that I'm keen on, however I'm most definitely inspired by this one. Recently felt that I would post and let you know. Weed for sale

Avatar_small
no excuses runner 说:
2020年11月29日 17:56

I was impressed with the site that you created, so memotipasi many people to be more advanced, there also kunjugi me, as a comparison wordsofwonders.site

Avatar_small
no excuses runner 说:
2020年11月29日 19:34

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. personalised hi vis workwear

Avatar_small
no excuses runner 说:
2020年11月29日 20:46

Man's lives, such as uncontrolled huge amounts, definitely not while countries furthermore reefs, challenging to seismic disturbance upward perfect apply. 먹튀검증업체

Avatar_small
no excuses runner 说:
2020年11月30日 16:35

A debt of gratitude is in order for posting this information. I simply need to tell you that I simply look at your site and I discover it exceptionally fascinating and educational. I can hardly wait to peruse bunches of your posts. Holistic Wellness Blog

Avatar_small
no excuses runner 说:
2020年11月30日 17:50

I appreciate several from the Information which has been composed, and especially the remarks posted I will visit once more. celestial pullover hoodie

Avatar_small
no excuses runner 说:
2020年11月30日 19:51

Thankyou for sharing the data which is beneficial for me and others likewise to see. Hack Community Forums

Avatar_small
no excuses runner 说:
2020年11月30日 20:48

Extraordinary things you've generally imparted to us. Simply continue written work this sort of posts.The time which was squandered in going for educational cost now it can be utilized for studies.Thanks Haselünne Haus kaufen

Avatar_small
marleoi 说:
2020年12月01日 00:17

awesome! Therefore, recognizing the needs of buyers is one of the key issues in e-commerce. fo buy website traffic now can help?

In this regard, paying attention to analytics data to study the behavior of users on the site and also analyzing social networks to see what users share can be very useful and helpful.
The word " related " is very important. Because Google aims to show the most relevant results to the query.
 If the site is not displayed in the list of search results, the user will not enter the site through the search engine and therefore the site traffic will be low.
And if the person does not find the content and item they are looking for when Buy Website Traffic that converts, the site conversion rate will decrease. 

Avatar_small
targeted web traffic 说:
2020年12月01日 00:33

Today, mobile advertising has made significant progress compared to previous years, and this method has many advantages over other advertising methods. In this educational article, you will get acquainted with different methods of advertising through mobile phones and applications. Buy Targeted Mobile Traffic With the passage of time and the advancement of technology, communication tools and ways have also evolved and saved a lot of money and time for users. Therefore, it is very natural that advertising methods have also undergone changes. And the cost has replaced the previous methods, and if you are looking to better introduce your services and products and do not have a lot of capital for very high advertising costs such as TV, newspaper or street billboards, one of the best options for you is mobile advertising. Buy Targeted Mobile Traffic| Boost Mobile Traffic |

Avatar_small
no excuses runner 说:
2020年12月01日 18:44

Whoi, excellent, t wondered just how to cure icne. ind found your webstte by google, dtscovered todiy t'm i ltttle obvtous i greit deil. t’ve ilso idded RSS ind sive your webstte. keep us updited. Automotive detailing

Avatar_small
no excuses runner 说:
2020年12月01日 19:27

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. ข่าวบอลต่างประเทศ

Avatar_small
no excuses runner 说:
2020年12月01日 20:09

I'm constantly searching on the internet for posts that will help me. Too much is clearly to learn about this. I believe you created good quality items in Functions also. Keep working, congrats! ข่าวบอลออนไลน์

Avatar_small
no excuses runner 说:
2020年12月01日 21:51

Extraordinary things you've generally imparted to us. Simply continue written work this sort of posts.The time which was squandered in going for educational cost now it can be utilized for studies.Thanks psychedelics for sale

Avatar_small
no excuses runner 说:
2020年12月02日 19:32

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. site de streaming gratuit et légal

Avatar_small
Robinjack 说:
2020年12月23日 17:32

After study a few of the websites on the website now, and i genuinely much like your way of blogging. I bookmarked it to my bookmark internet site list and will also be checking back soon. Pls have a look at my internet site as well and let me know what you think. cool medical masks

Avatar_small
desawar satta 说:
2020年12月24日 15:04

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. desawar satta

Avatar_small
SLOT88KU 说:
2023年11月20日 15:56

<a href="https://slot88ku.vip/">SLOT88KU</a> - Merupakan Website Game online resmi yang hadir untuk kalian semua dengan menyuguhkan berbagai macam permainan dimana game nya bisa membawa kalian mendapatkan keuntungan besar Daftar Klik Disini


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter