管理 Java 属性文件的本地化

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1365419/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 16:16:23  来源:igfitidea点击:

Managing the localization of Java properties files

javalocalizationproperties

提问by andri

I have a Web application written in Java that is targeting several countries, all of which speak different languages (and more often than not, several languages -- that's Europe for you).

我有一个用 Java 编写的 Web 应用程序,它面向多个国家/地区,所有国家/地区都使用不同的语言(而且通常有几种语言——对您来说是欧洲)。

We have a bunch of .propertiesfiles that hold the localized strings, and our current procedure is to e-mail the language-specific files to our partners for updating before doing major updates.

我们有一堆.properties保存本地化字符串的文件,我们当前的程序是在进行重大更新之前将特定于语言的文件通过电子邮件发送给我们的合作伙伴进行更新。

However, this process is rather error-prone, as sometimes people forget to translate new strings and sometimes new strings don't get added to every language file, thus small mistakes get through very easily.

然而,这个过程相当容易出错,因为有时人们忘记翻译新字符串,有时新字符串不会添加到每个语言文件中,因此很容易出现小错误。

Does anyone know of any existing software that could help us clear this mess?

有谁知道任何现有的软件可以帮助我们清理这个烂摊子?

At a bare minimum, I'm thinking of something that would allow you to load a master file (for example, in English), a localized file and then would highlight the keys that were added to or removed from the master file.

至少,我正在考虑允许您加载主文件(例如,英文)、本地化文件,然后突出显示添加到主文件或从主文件中删除的键的东西。

回答by ChssPly76

I've used Jintofor that purpose as well as EPFE(older version, haven't tried the newest one).

我用Jinto用于这一目的,以及EPFE(旧版本,还没有试过最新的一个)。

Both are Eclipse plug-ins, both are quite decent if you can get past the fact that they will reorder keys in your resource bundles. Then there's also Babel- I haven't tried it personally so I don't know how good it is.

两者都是 Eclipse 插件,如果您能够克服它们将重新排序资源包中的键的事实,那么它们都是相当不错的。然后还有Babel- 我没有亲自尝试过,所以我不知道它有多好。

回答by ahus1

we are using https://webtranslateit.com/as a hosted service.

我们使用https://webtranslateit.com/作为托管服务。

Our continuous integration server uploads our (english) Java property file whenever there are changes. The users for the different languages can then log in and update their translations.

只要有更改,我们的持续集成服务器就会上传我们的(英文)Java 属性文件。然后,不同语言的用户可以登录并更新他们的翻译。

There is a nice API that allowed us to fetch translations "on the fly" for our web application, but this is an internal solution only at the moment.

有一个很好的 API 允许我们为我们的 Web 应用程序“即时”获取翻译,但这只是目前的内部解决方案。

When there is a release, we download the files, bundle them with our application and deploy it.

当发布时,我们下载文件,将它们与我们的应用程序捆绑在一起并进行部署。

The solution highlights what is translated, untranslated, needs verification, offers a translation memory, and integration i.e. to Google Translate.

该解决方案突出显示已翻译、未翻译的内容、需要验证的内容、提供翻译记忆库以及与 Google 翻译的集成。

Best regards, Alexander.

最好的问候,亚历山大。

回答by Mike Sickler

Netbeanshas a really excellent Java properties editor that shows you each of the locales side-by-side. You can easily see which properties are absent for different languages.

Netbeans有一个非常出色的 Java 属性编辑器,可以并排显示每个语言环境。您可以轻松查看不同语言缺少哪些属性。

回答by mromaine

For importing, managing, and potentially even ordering translations for languages you don't have in-house translators for, myGengo's String (http://mygengo.com/string/about) is a free hosted solution. Supports importing of various language-files for a variety of platforms. (Full disclosure - I'm a co-founder of myGengo)

为了导入、管理甚至可能订购您没有内部翻译人员的语言的翻译,myGengo 的字符串 (http://mygengo.com/string/about) 是一个免费的托管解决方案。支持导入各种平台的各种语言文件。(完全披露 - 我是 myGengo 的联合创始人)

回答by Omnaest

Even if this is out of time scope for the original poster:

即使这超出了原始海报的时间范围:

i18nBinder

i18nBinder

is an Ant Task for converting property files to an Excel XLS file.

是一个 Ant 任务,用于将属性文件转换为 Excel XLS 文件。

The locales are there placed in columns for each key (row).

语言环境放置在每个键(行)的列中。

Afterwards it writes the changes within the xls file back to the original files. Thats pretty handy and since you are using Excel to edit, everyone is familiar with that.

然后它将 xls 文件中的更改写回原始文件。这非常方便,因为您使用 Excel 进行编辑,所以每个人都很熟悉。

Best regards

最好的祝福

回答by DylanYi

What about localizedpropertiesEclipse plugin? It's similar to Jinto, but supports Eclipse version as higher as 3.6.

什么localizedpropertiesEclipse插件?它与 Jinto 类似,但支持 Eclipse 版本高达 3.6。

回答by lapo

Eclipse ResourceBundle Editorseems to be the newest (and nicer, IMHO) choice in the "Eclipse plugin" department.

Eclipse ResourceBundle Editor似乎是“Eclipse 插件”部门中最新的(更好的,恕我直言)选择。

enter image description here

在此处输入图片说明

回答by nicolimo86

I tried Everit - i18n Props XLS Converterand it does the job.

我尝试过Everit - i18n Props XLS 转换器,它完成了这项工作。

You can specify the location of yours .properties containing the translations and you'll get an .xls filled with all the values contained in them.

您可以指定包含翻译的 .properties 的位置,您将获得一个 .xls,其中包含其中包含的所有值。

At this point you can send the xls to your translators that will fill it with the right translations and then convert it back to .properties to use in your java project.

此时,您可以将 xls 发送给您的翻译人员,他们将使用正确的翻译填充它,然后将其转换回 .properties 以在您的 Java 项目中使用。

The project is hosted in github and it needs to be built using maven and jdk8.

项目托管在github,需要使用maven和jdk8构建。

回答by Aravind Yarram

I have been using JRC Editorfor managing the resource bundles. It will highlight the keys that are missing values as shown in the below screen shot.

我一直在使用JRC 编辑器来管理资源包。它将突出显示缺少值的键,如下所示截屏

It also allows you to work with the bundles using native language (hence end user friendly) and it will convert the characters to "\uxxx" equivalent behind the scenes.

它还允许您使用本地语言(因此对最终用户友好)处理捆绑包,并将在幕后将字符转换为“\uxxx”等价物。

回答by richj

sometimes people forget to translate new strings and sometimes new strings don't get added to every language file, thus small mistakes get through very easily.

有时人们忘记翻译新字符串,有时新字符串不会添加到每个语言文件中,因此小错误很容易解决。

I use a slightly different approach in that I send out .properties files containing the existing localized strings merged with the new untranslated strings in the order that I want them back.

我使用了一种稍微不同的方法,因为我发送了 .properties 文件,其中包含与新的未翻译字符串合并的现有本地化字符串,按照我希望它们返回的顺序。

The new strings are marked with "pseudo-translation" characters, so that untranslated strings are easy to find with a simple text search.

新字符串标有“伪翻译”字符,以便通过简单的文本搜索很容易找到未翻译的字符串。

The translators very rarely lose properties or forget to translate strings. The most common mistake is to forget to remove the pseudo-translation characters from the newly translated strings. The difference check before committing the new translations back into the revision control system is very good at catching these errors.

翻译人员很少丢失属性或忘记翻译字符串。最常见的错误是忘记从新翻译的字符串中删除伪翻译字符。在将新翻译提交回修订控制系统之前的差异检查非常擅长捕捉这些错误。

This system works really well, and now that it is semi-automated it takes about an hour to do each localization update instead of the 1 - 2 days it used to take when the process was completely manual.

这个系统运行得非常好,现在它是半自动化的,每次本地化更新需要大约一个小时,而不是过去完全手动过程需要 1 - 2 天。

I wrote my own tool to generate the merged files and do a three-way comparison between the new masters, the old localized files and the newly generated merged files, but any tool that merges changes in the same way would work with this process.

我编写了自己的工具来生成合并文件,并在新主文件、旧本地化文件和新生成的合并文件之间进行三向比较,但是任何以相同方式合并更改的工具都可以使用此过程。