本文介绍了Gettext或数据库翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪个更好:

  1. gettext
  2. 基于MySQL +缓存的自定义功能

Gettext是一种内置功能,因此我认为它已针对性能进行了调整.使用poedit是一件痛苦的事,不可能向任何客户展示.

Gettext is a sort of builtin feature, so I assume it's tweaked for performance. Using poedit is a pain and impossible to show to any client.

自定义功能允许简单的翻译界面.但是可能会大量使用php/db.

A custom functionality allows for simple translation interface. But might be heavy on php/db usage.

我想,您什么时候会用哪个?

I suppose, which one would you use when?

推荐答案

本地化很困难.真的很难.它不仅是"pairs of words" => "Wortpaare",而且比这要复杂得多.大多数人在看gettext并丑陋,丑陋" 时会忘记的是,本地化 process 比实现的技术细节重要得多.这是因为实际的翻译人员通常不是程序员,甚至可能不在内部.这比您想象的要麻烦得多. gettext确实很旧,已经过测试,并且背后有巨大的工具链,可以调整以支持此过程.如果要正确执行i18n和l10n,则需要功能强大的系统. gettext就是这样,并且得到了广泛工具的支持.您的Homebrewed Translation System™不会.

Localization is difficult. It is really difficult. It's not just "pairs of words" => "Wortpaare", it's a lot more complex than that. What most people forget when they look at gettext and go "Ugh, ugly" is that the localization process is a lot more important than the technical details of the implementation. That's because the actual translators are typically not programmers and are probably not even in-house. This causes a lot more headaches than you may think. gettext is really old, is battle tested and has a huge toolchain behind it that is tuned to support this process. If you want to do i18n and l10n properly, you need a powerful system. gettext is that and has support from a wide range of tools. Your Homebrewed Translation System™ does not.

首先,您需要一个强大的系统来提取可翻译字符串.不能自动且可复制地从源代码中提取可翻译字符串,您需要为每个要翻译的新字符串进行大量工作.在gettext中,xgettext可以做到这一点.

First of all, you need a robust system to extract translatable strings. Without being able to automatically and reproducibly extract translatable strings from source code, you have a mountain of work for each new string you want to translate. In gettext, xgettext does that.

接下来,您需要一个工具来将提取的字符串与已经存在的翻译进行同步,以确保不会丢失任何翻译,并且在可能的情况下仅保留稍作更改的翻译.在gettext中,msgmerge可以做到这一点.

Next, you need a tool to synchronize the extracted strings with already existing translations in a way that no translations are lost and that only slightly changed translations are kept if possible. In gettext, msgmerge does that.

接下来,您想要一种向字符串添加额外信息的方法.您希望能够按类别,域"和上下文将它们分组,您可能希望将翻译的注释添加到源代码中,并且您可能希望翻译器能够将注释添加到翻译中. gettext支持所有这些功能.

Next, you want a way to add extra information to strings. You want to be able to group them by category, "domain" and context, you may want to add comments for the translator to the source code and you may want translators to be able to add comments to the translations. gettext supports all that.

接下来,您想要一种可以在各种工具中获得良好支持的文件格式,因为您可能会将文件发送到中国,以便在那里进行翻译.您可能将它们发送给外部翻译器的原因也是您需要一个好的同步工具来合并更改的原因,因为这可能是一个非常异步的过程.很好地支持PO文件,因为gettext太旧了.根据您的特定需求,有许多开源和商业工具可以在多个级别支持本地化过程.

Next, you want a file format that has good support from a variety of tools, since you may be sending your files to China to get them translated there. The reason you may be sending them away to external translators is also the reason you need a good synching tool to merge changes, since this can be a very asynchronous process. PO files are very well supported, because gettext is so old. There are many open source and commercial tools that support the localization process at many levels, depending on your specific needs.

不要低估本地化的任务,选择一个非常适合该过程的工具并学习它. gettext是一个很棒的工具,即使不是最适合初学者也是如此.

Do not underestimate the task of localization, choose a tool that is well suited for the process and learn it. gettext is a great tool, if admittedly not the most beginner friendly.

对于它的价值,这是我对Twig的gettext扩展,使PHP的gettext更好.

For what it's worth, here's my gettext extension for Twig, which makes gettext for PHP even better.

这篇关于Gettext或数据库翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 04:37
查看更多