简体   繁体   English

最好使用多个语言文件还是1个?

[英]Better to use multiple language files or 1?

From your experience, is it better to use 1 language file or multiple smaller langauge files for each language in a PHP project using the gettext extension? 根据您的经验,在使用gettext扩展名的PHP项目中为每种语言使用一种语言文件还是使用多个较小的语言文件更好? I am not even sure if it is possible to use multiple files, it is hard for me to test since the server caches the language files. 我什至不确定是否可以使用多个文件,因为服务器缓存了语言文件,所以我很难测试。

I am doing multiple languages on a social network site, so far just the signup page which is about 1 out of 200 pages to go and it has 35 text strings to translate, at this pace the language file for each language wold be really large so I was thinking maybe it would be better to do different language files for differnt pages or perhaps sections like forums section and blogs section but if it makes no difference then I would ratther not waste my time in making multiple smaller files for each language. 我正在社交网站上使用多种语言,到目前为止,注册页面仅占200页中的1页,并且具有35个文本字符串可以翻译,按照这种速度,每种语言的语言文件都非常大,因此我当时在想为不同的页面或论坛部分和博客部分之类的页面使用不同的语言文件可能会更好,但是如果没有区别的话,我将不会浪费时间为每种语言制作多个较小的文件。

I realize every situation is different and the only real answer is to test it but I am hoping to avoid that this time and just get some oppinions of people more experienced, this is my first time using gettext, thanks 我意识到每种情况都是不同的,唯一的真实答案就是要对其进行测试,但是我希望避免这次,只是让一些经验更丰富的人反对,这是我第一次使用gettext,谢谢

I would have the language files module based. 我将基于语言文件模块。 With gettext you need to specify locale for each language. 使用gettext,您需要为每种语言指定语言环境。 It would fit best to have a separate .po/.mo files for each module or big parts of your site. 最好为网站的每个模块或大部分使用单独的.po / .mo文件。

That's my opinion. 那是我的意见。 :-) :-)

I typically automate the process and have multiple languages in multiple files by using a database to edit the site (using a simple db lookup). 我通常会自动执行该过程,并通过使用数据库来编辑站点(使用简单的db查找)来在多个文件中使用多种语言。 This lets me hire translators to come in and verify the current translation easily. 这使我可以雇用翻译人员来轻松验证当前翻译。 Deploying to production then is simply turning the database into a set of language files. 然后,部署到生产环境只是将数据库变成一组语言文件。

From experience i would break the languages down on a per file basis as the management overhead becomes heavy and there is great scope for duplication and mistakes. 根据经验,随着管理开销变得越来越重,并且存在很大的重复和错误范围,我会按文件划分语言。

The other advantage it that by using a directory structure and naming convention the correct language can be selected programatically more easily than the large file and it is easier to write management tools at a later stage in the project. 另一个优点是,通过使用目录结构和命名约定,可以比大文件更容易地以编程方式选择正确的语言,并且在项目的后期阶段更容易编写管理工具。

It is also worth looking at some of the formats other people use. 还值得一看其他人使用的某些格式。 Many of the Frameworks use this sort of structure, Dashcode, Symfony, Zend etc. And there is an xml format xliff which is built to handle translation and integrates with many of the tools that translators use. 许多框架都使用这种结构,例如Dashcode,Symfony,Zend等。XML格式的xliff可以处理翻译并与翻译人员使用的许多工具集成在一起。

Multiple files are the best way to go, but things can get disorganized. 最好使用多个文件,但是事情会变得混乱。

We've just launched a free new service called String which solves most of the problems of managing multiple language files - like a basecamp for localization. 我们刚刚启动了一项免费的名为String的新服务,该服务解决了管理多种语言文件的大多数问题,例如本地化的基本训练。 You can either import existing files, or start from scratch with keys and strings in the system. 您可以导入现有文件,也可以从头开始使用系统中的键和字符串。 When you're ready, you can export the files again to run your app. 准备就绪后,可以再次导出文件以运行您的应用程序。 It works with PHP (array), PHP (define), po, yaml, ini and .strings formats. 它适用于PHP(数组),PHP(定义),po,yaml,ini和.strings格式。

String allows you to collaborate with translators easily - you just invite them to a project and set their language permissions. 字符串使您可以轻松地与翻译合作-您只需邀请他们参加项目并设置他们的语言权限即可。 Translators can leave comments and questions on each string if they need more info - and you can revert strings back using the History function if things aren't quite right. 如果翻译人员需要更多信息,他们可以在每个字符串上留下评论和问题-如果情况不太正确,您可以使用历史记录功能将字符串还原。

Anyway enough sales pitch! 无论如何,足够的销售宣传! Check it out at http://mygengo.com/string - we'd love your feedback. http://mygengo.com/string上查看它-我们希望收到您的反馈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM