What format of files in internationalization files - ruby-on-rails

I'm working on internationalization of applications. I wonder whether it is better to keep in YAML files unformatted text versions of the static example, all begin with a lowercase letter, and small caps are created each time the view (method capitalize). The advantage of the method is that when creating subsequent files translator does not need to pay attention to the size of the characters and the downside may be the time overhead associated with multiple calling the helper in the view.

Different languages have different capitalization rules so it might not be a good idea. For example I should capitalize 'i' when talking about myself in english.

Related

Best practices to keep strings in one place

I'm setting up a new iOS project and wondering if I should use a Localizable.strings file to keep my strings even without planning to add support for other languages.
I've tried using struct to keep my strings before but I am wondering if this is a good practice. Using Localizable.strings will also work well on the library R.swift, another reason why I am struggling to choose a strategy.
There is no "best practice" in this case. There are practices and some may be a bit more appropriate for your case than others.
You are saying that you are not planning to add support for other languages but it seems like you want to be prepared for it if you change your mind. So first thing is to ask yourself what is the actual problem you are looking solution for. I would say the problem is the overhead you get once app is already out and you need to hunt all the strings you have used in your app and wrap them into NSLocalizedString. This usually includes endless testing and you will still in the end most likely forget to localize at least some strings.
You can from beginning start wrapping things into NSLocalizedString which will in the end help you extract all the strings using native tools from your code. The problem then are still Storyboards; not as much extracting strings from storyboard but removing those default texts you have no plan to translate (Like "Name" will actually be some name and should not be translated). So in my experience this is a half solution.
To solve the Storyboard issue there should be a tool (I can't remember which, maybe some other CocoaPod) which enables you to ignore views that should not be translated. So in this case you need to use 2 things; NSLocalizedString and ignoring untranslatable items in IB.
As you already put it nicely you can use R.Swift to get strings directly from your strings file. This is very neat but also extremely distracting as you develop. Doing so you are forcing developer to first enter a text in strings file before he can use it. Personally I hate that. Also this can be a problem with multiple developers being in conflict. Not to mention this hasn't nearly fixed your issue with Storyboards.
Creating a separate structure system to hold all the strings does work pretty nicely. You don't have to hunt down all of the strings in your code and you don't need to jump to strings file (going to another source is much more pleasant when developing since you can navigate to it very easily). You do also preserve a good structure, assuming you maintain it like label.text = Strings.Settings.User.firstNamePlaceholder which helps you to easily find strings you need or are deprecated. You can remove whole screens with great ease. But it still is an overhead for developer plus you still have an issue that now you need to drag all the outlets from storyboard to set the localized strings to them.
Doing this procedure you can in the end choose to use NSLocalizedString directly or to use R.Swift. In fact you can just use nothing and you will still not have much overtime switching to any of the two (again assuming that hunting down those strings in the code takes most of the time).
Personally I would go with nothing at all or go with creating a custom structure system which then uses nothing but just returns raw strings. But this all really depends on what size is your project of, what type of project, how many things are in Storyboards... It also depends on when you expect to have more resources so you either spend more time now and don't bother later or you simply do it simplest now prepare for a lot of work when localization is indeed needed (hopefully when that happens it is one of the "sweet" problems because it means you have tons of users).

Dealing with multiple languages in Ranorex?

For my automated tests, everything works fine, except only when it is in English, and this script needs to be able to run for Spanish versions of the same application too. I am not even sure if this is possible, but is there some way of making Ranorex do some sort of translations or some sort?
Currently, validation doesn't work because obviously the text is in a different language, how can I get around this? If it is even possible.
Usually, when testing an application which can be represented in different languages I would suggest using language independent properties in the RanorexPath (for example an automation id if available).
There are similar questions discussed in the Ranorex forum.
http://www.ranorex.com/forum/nls-testing-local-language-testing-t8438.html
http://www.ranorex.com/forum/localized-t3725.html#p15532
I hope that helps.
I have the exact same issue, and in fact, the displayed message/title is sometimes part of what I want to check depending on the chosen language.
What I did:
My different languages are handled through an xml file
the detection of my UI elements may be based on title (but I prefer unique ID when possible, like user1982826 said), in such a
case, I make that title a variable through XSpy.
In a code collection, I created a method that will initialize those
variables depending on the expected language (I'm using xdocument to
parse my xml)
Then, I call that method at the beginning of the recordings needing those variables (don't forget to bind them).
It's not perfect (I need to call that method multiple times for the moment), but ranorex support pointed me that using databinding from supported external source should do the trick. In my case, I should be able to trasnform my xml in a CSV file at the very beginning of my testsuit, and then use databinding on that file with the very same variables I created: data-driven-testing
Don't know if it's helping, it probably depends on how you handle the different languages of your application...
Also you can build your validations around different languages. Basically you'd just set a flag as a global parameter or a parameter that's held in the Program.cs-s Main method.
So if flag is set to "Spanish" it would do the spanish validations and if "English" the same would apply. You'd just have to capsulate the validations correctly in an if/else statements with userCode modules.

How do they unofficially translate a compiled program from one human language to another?

I've seen that there are unofficial fanmade English translation patches for several Japanese games. I can see that the Japanese strings in the program have to be modify into English and any Japanese text in the textures have to be modified.
Now, I am wondering what are some of the tools they use to know where to look for these resources and possibly how to modify the binary and other things and still make the game work?
Generally, this is done using software that can extract and modify resources in an executable file and modify them in place. Depending on the specific application and/or operating system, this approach will allow you to modify icons, menus, strings, and the labels on UI controls, among other things.
A common utility for this purpose was Resource Hacker by Angus Johnson. However, it is no longer under active development, and has not been released as open source. Other alternatives include:
XN Resource Editor
Resource Hacker FX
For example, in the screenshot below I am using Resource Hacker to modify one of the dialog boxes used by the 7-Zip File Manager application:
A hexadecimal editor of your choice can also be used to make modifications to the raw, binary source code that is compiled into the executable file. This can allow you to make changes to strings that haven't been placed into a string table for easy modification.
It's worth noting that this is a much more error-prone way of making modifications. It's extremely easy to corrupt the binary by overriding the wrong sequence. Generally, you must replace a string with another string of exactly the same length.
And, of course, always work on a copy of the original executable!

Designing a Non-Specific Language Application, e.g. planning for localization

Made this community wiki :3
I'm developing a basic RPG, and one of my goals from the beginning is to make sure that my program is language non-specific. Basically, before I design or start programming any menus, I want to make sure that I can load and display them out of supported languages so I am not hard-coding in values.
(It would save me from many migranes down the road)
For this example, let's use Western Left-to-Right languages. English, Spanish, German, French, Italian.
This is a basic example of what I have.
One XML file contains a mapping and design of a conversation.
<conversation>
<dialog>line1</dialog>
<dialog>line2</dialog>
</conversation>
Other XML files contains the definitions.
<mappings language="English">
<line1>This is line 1 in English!</line1>
<line2>Other lines are contained in language-separated xml files</line2>
</mappings>
Heh. This would work great, besides the fact that I forgot that English doesn't assign genders to their words, whereas other languages do. So, where one sentence might be enough in English, I might need to have two sentences in other languages, one to cover the masuline tense and the other to cover the feminine tense.
What would be the most condusive way of solving this problem? Right now, I've considered coming up with different mapping tables, one excuslively for masculine-tense sentences whereas the other table would cover just feminine-tenses. Or just reading from different defintion tables.
And another kicker would be based within my game data design. I never thought about it, but I might need to store within my game items and characters their sexes so I can use the correct sentence. However, other languages might have their own specific quirks that I would need to consider as well (though thankfully, from what I know Italian and Spanish are relatively similar, and French possibly as well.)
So, obviously this is a huge task ahead of me. What other design considerations should I think of? Rightnow, I'm thinking a static class would be easiest. Configure selected language at startup, throw in inputs and hopefully get a string back.
Any ideas (looking to throw ideas around :P)
There's two general ways to approach this: brute force and trying to be clever. Brute force means writing each possible line and including it with your XML files. It's a lot of work, but it will work.
Trying to be clever gets into deep water, fairly fast, particularly if you're trying to cover a whole lot of languages.
You need to keep more information about characters than gender. In Russian, for example, there are different words meaning "you" depending on whether you're being informal or formal (or talking to multiple people), and the verb endings are also different. There are different translations of "please pass the bread" depending on the formality. In other languages, getting the translation right depends on social status.
There are issues, as pawel_dyda pointed out, with singular, plural, and possibly dual case. Other languages also use different word orders: "The arrows are X coppers each, so to buy Y arrows you'll need Z silver" may require you to keep track of the order of the numbers.
Visual C++ and MFC come with internationalization facilities that are actually pretty good. You'd keep the strings in a resource file, and it's possible to substitute numbers and the like in while keeping the order correct for different languages.
Look up "internationalization" (often abbreviated to "i18n") on the web. There's plenty of stuff out there.
As for genders you may try encourage translators to use non-gender specific translations (which is usually possible in business applications but might be impossible here).
You may have also encounter the problem somewhere else. Other (non-English) languages have multiple plural forms. For example: "Your team has acquired 2 swords". No matter how many swords you will actually receive, be it 5 or 1000, in English you will always end up with one plural sentence. But this is not the case in many languages.

What is the best way to store multiple language versions of a website?

My web site (on Linux servers) needs to support multiple languages.
What is the best practice to have/store multiple languages versions of the same site?
Some I can think of:
store in DB
different view file for each language
gettex
hard coded words in PHP files (like in phpBB)
With web sites, you really have several categories of content to consider for localization:
The article-type content elements that you would in many cases create, edit and publish in a CMS.
The smaller content blocks that are common to every page (or a sub-group of pages), such as tagline, blurb, text around a contact form, but also imported content such as a news ticker or ads and affiliate links. Some of these may only appear for one language (for example, if you don't offer some services in some regions, or don't have, say, language-appropriate imported content for a particular language: it can be better to remove an element rather than offering English to people who may not speak it).
The purely functional elements, like "Click here to comment", "More...", high-level navigation, etc., which are sometimes part of your template. Some of these may be inside images.
For 1. the main decision is using a CMS or not. If yes, you absolutely need to choose one that supports multiple languages. I'm not up-to-date with recent developments in PHP CMS's, but several of the Django CMS apps (Django-CMS-2, FeinCMS) support multi-language content. Don't forget that date stamps, for example, need to be localized, too (or you can get around this by choosing ISO dates, though that may not always be possible). If you don't use a CMS, and everything is in your HTML files, then gettext is the way to go, and keep the .mo files (and your offline .po files) in folders by language.
For 2. if you have a CMS with good multi-lingual support, get as much as possible inside the CMS. The reason is that these bits do change, and you want to edit your template as little as possible. If you write code yourself, think of ways of exporting all in-CMS strings per language, to hand them to translators. Otherwise, again, gettext. The main issue is that these elements may require hard-coding language-selection code (if $language = X display content1 ...)
For 3., if it's in your template, use gettext. For images, the per-language folders will come in handy, and for heaven's sake make choose images the generation of which can be automated, or you (or your graphic artist) will go mad with editing 100s of custom images with strings in languages you don't understand.
For both 2. and 3., abstracting from the language selection may help selecting the appropriate blocks or content directory (where localized images or .mo files are kept).
What you definitely want to avoid is keeping a pile of HTML files with extensive text content in them that would be a nightmare to maintain.
EDIT: Everything about gettext, .po and .mo files is in the GNU gettext manual (more than you ever wanted to know) or a slightly dated but friendlier tutorial. For PHP, there's are the PHP gettext functions, and also the Zend Locale documentation
I recommend using Zend_Translate's Gettext adapter which parses mo files. Very efficient + caching. Your calls would be like
echo $translation->_("Hello World");
Which would find the locale specific key for that specified string.
Check out i18n support for php: http://php-flp.sourceforge.net/getting_started_english.htm

Resources