Gettext:消息ID为英文文本是个好主意吗? [英] Gettext: Is it a good idea for the message ID to be the english text?

查看:95
本文介绍了Gettext:消息ID为英文文本是个好主意吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正准备将我们的PHP网站翻译成各种语言,而PHP中对gettext的支持似乎是一种发展之路.

We're getting ready to translate our PHP website into various languages, and the gettext support in PHP looks like the way to go.

我看到的所有教程都建议使用英文文本作为消息ID,即

All the tutorials I see recommend using the english text as the message ID, i.e.

gettext(那里!")

gettext("Hi there!")

但这真的是个好主意吗?假设某位行销人员想将文字更改为大家好!".那么,您是否不必更新所有语言文件,因为该字符串(实际上是消息ID)已更改了?

But is that really a good idea? Let's say someone in marketing wants to change the text to "Hi there, y'all!". Then don't you have to update all the language files because that string -- which is actually the message ID -- has changed?

拥有某种通用ID(例如"hello.message")和英语翻译文件更好吗?

Is it better to have some kind of generic ID, like "hello.message", and an english translations file?

推荐答案

我使用有意义的ID,例如"welcome_back_1",即"welcome back, %1"等.我始终以英语为基础"语言,因此在最糟糕的情况是当特定语言没有消息ID时,我会转而使用英语.

I use meaningful IDs such as "welcome_back_1" which would be "welcome back, %1" etc. I always have English as my "base" language so in the worst case scenario when a specific language doesn't have a message ID, I fall-back on English.

我不喜欢使用实际的英语短语作为消息ID,因为如果英语更改,ID也将更改.如果您使用一些自动化工具,这可能不会对您造成太大影响,但是这使我感到困扰.我不喜欢使用简单的代码(例如msg3975),因为它们没有任何意义,因此除非您到处乱扔注释,否则阅读代码会更加困难.

I don't like to use actual English phrases as message ID's because if the English changes so does the ID. This might not affect you much if you use some automated tools, but it bothers me. I don't like to use simple codes (like msg3975) because they don't mean anything, so reading the code is more difficult unless you litter comments everywhere.

这篇关于Gettext:消息ID为英文文本是个好主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆