简体   繁体   English

管理Java属性文件的本地化

[英]Managing the localization of Java properties files

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 .properties files 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. 至少,我正在考虑允许您加载主文件(例如,英语),本地化文件,然后突出显示添加到主文件或从主文件中删除的键的内容。

I've used Jinto for 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. 两者都是Eclipse插件,如果您可以通过他们将重新排序资源包中的密钥的事实,两者都相当不错。 Then there's also Babel - I haven't tried it personally so I don't know how good it is. 然后还有Babel - 我没有亲自尝试过,所以我不知道它有多好。

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. 只要有变化,我们的持续集成服务器就会上传我们的(英语)Java属性文件。 The users for the different languages can then log in and update their translations. 然后,不同语言的用户可以登录并更新其翻译。

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 ie to Google Translate. 该解决方案突出了翻译,未翻译,需要验证,提供翻译记忆和整合,即谷歌翻译。

Best regards, Alexander. 此致,亚历山大。

Netbeans has a really excellent Java properties editor that shows you each of the locales side-by-side. Netbeans有一个非常出色的Java属性编辑器,它可以并排显示每个语言环境。 You can easily see which properties are absent for different languages. 您可以轻松查看不同语言的哪些属性不存在。

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. 对于导入,管理甚至可能为您没有内部翻译器的语言订购翻译,myGengo的String(http://mygengo.com/string/about)是一个免费的托管解决方案。 Supports importing of various language-files for a variety of platforms. 支持为各种平台导入各种语言文件。 (Full disclosure - I'm a co-founder of myGengo) (完全披露 - 我是myGengo的联合创始人)

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. 然后,它将xls文件中的更改写回原始文件。 Thats pretty handy and since you are using Excel to edit, everyone is familiar with that. 这非常方便,因为你使用Excel编辑,每个人都熟悉它。

Best regards 最好的祝福

What about localizedproperties Eclipse plugin? 那么本地化的 Eclipse插件怎么样? It's similar to Jinto, but supports Eclipse version as higher as 3.6. 它与Jinto类似,但支持Eclipse版本高达3.6。

Eclipse ResourceBundle Editor seems to be the newest (and nicer, IMHO) choice in the "Eclipse plugin" department. Eclipse ResourceBundle编辑器似乎是“Eclipse插件”部门中最新的(更好的,恕我直言)选择。

在此输入图像描述

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

I tried Everit - i18n Props XLS Converter and it does the job. 我尝试了Everit - i18n Props XLS Converter ,它完成了这项工作。

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构建。

I have been using JRC Editor for managing the resource bundles. 我一直在使用JRC编辑器来管理资源包。 It will highlight the keys that are missing values as shown in the below 它将突出显示缺少值的键,如下所示 屏幕截图 .

It also allows you to work with the bundles using native language (hence end user friendly) and it will convert the characters to "\\uxxx\u0026quot; equivalent behind the scenes. 它还允许您使用本机语言处理捆绑包(因此最终用户友好),它将在后台将字符转换为“\\ uxxx”。

The CAL10N project is intended to deal with this problem. CAL10N项目旨在解决此问题。 It builds upon resource bundles by adding verification primitives. 它通过添加验证原语来构建资源包。 It is also rather easy to use. 它也很容易使用。

The answer is a little late, but for future reference there is also Tongue-Tied . 答案有点晚,但为了将来的参考,还有舌头绑 It is an open source, web based application for managing static resources and translations. 它是一个基于Web的开源应用程序,用于管理静态资源和翻译。 Translations can be entered via the web interface. 可以通过Web界面输入翻译。 It supports the importing/exporting of many formats like java properties files, excel file, csv etc. It also has a small workflow built in if needed. 它支持导入/导出许多格式,如java属性文件,excel文件,csv等。如果需要,它还内置了一个小工作流程。

Disclaimer : I am the project lead. 免责声明 :我是项目负责人。

Wow, I am surprised how crazy is that people did not explore the obvious import in Excel. 哇,我很惊讶人们没有在Excel中探索明显的重要性。

Go to Excel -> import -> select the properties file (Select all files in open file type). 转到Excel - >导入 - >选择属性文件(选择打开文件类型中的所有文件)。

It will ask you if you would like the columns to be delimited, check that option. 它会询问您是否要对列进行分隔,请检查该选项。

On the next screen of the import process, it would ask what kind of delimiter you want, select other and put "=" in the box (without the quotes) 在导入过程的下一个屏幕上,它会询问您想要哪种分隔符,选择其他并在框中输入“=”(不带引号)

Select next and voila. 选择下一个,然后瞧 You have a excel sheet with the properties ready to go. 你有一张excel表,准备好了。

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

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