Adding new translations - localization

I'm using FormatJS to localize my app. There's a handy CLI to extract all the translations from the code base. I can generate the en.json file, and send it to the translator. When I get the translation back I can save this as fr.json. So far so good.
What I don't understand is what to do when I'm adding new translations in my app. When I run formatjs extract again, I get a new en.js file, with all the keys. Obviously I don't want to send the whole thing again to the translator. I could diff the new en.json against the previous version but it's such a basic step that I feel like I must be missing something? I didn't find anything about this in the docs.
How is this part of the workflow handled with FormatJS?

It seems like translation services typically take care of diffing the data. You send them the whole template file and they send back translation files will all the translated strings (new ones + ones that have already been translated). At least that's how it works with the provider my company uses.
My workflow is as follow:
add new translations in the source code with intl.formatMessage()
formatjs extract to create the new en.json file (template file)
replace the translation files (e.g. es.json, fr.json etc.) with the new ones from the provider
formatjs compile to generate the machine files
I also created a test to ensure that each key in en.json has a corresponding key in each translation file.

Related

How can we integrate resource file with any translation management tool

I am working on multilingual site developed in asp.net MVC. Currently we are managing the translation task using resource (resx) file and everything is working fine.
Now as per client requirement, they want to integrate our resource file to a TMS "phrase" through a webhook. So in future, if they create any new key or modifying the existing resource file. Its automatically reflects in application resx file and it should automatically reflects on dev/test/prod environment.
As I tried to update the resource file on API call, its get modified and changes are reflected on application.
But when we modified the resx file under app_GlobalResources folder then it restarts the whole application. so this is one of drawback to use this approach. Also when we deploy our changes then it makes the dll of app_globalreources. Post deployment, unable to add new or make changes in existing translation.
Can any one suggest a best approach, which we should consider to fulfill above requirement.
Edit:-
Can we use json instead of resx file in existing application.
A common way to do translations is through database instead resource files. You save the same information in your database: language, key (the resource name) and value (the translated text).
With this focus, you must develop a way to do translations (the typical CRUD operations) and some layer to get any key in each language.
Talk with your client and check how important is this feature. I worked in a project like this some time ago and, at the end, we never do translations in this way. We add more functionality, made changes, translations and, when iteration finished, we move to production everything. Maybe not your case but it's a pity work on something that later hasn't use.

Copy only new added files from one folder to another, without moving the existing files from source folder

I am doing file integration using mirth. There is one software which generate the HL7 files. I want to read data from that files, without moving them to another destination. Next time when I want to read data, at that time it'll ignore the files from which the data are already read (i.e.Just read the new files data which are generated after last data read).
I had done this but I'll achieve it when I modify the original filename, if I am not modifying the filename then it'll read the duplicate data.
Is there is any solution for this problem, so we can read data from the files which are generated new. I am using mirth 3.5.1 version and HL7 v2 messages.
Thanks in advance.
Thanks #daveloyall, I am posting your comment as a answer here.
When you rename a file at the time you process it, for example, to add a .DONE suffix to the filename, you are adding information that can be used later. The part of the channel that reads files could be configured to skip files that have the .DONE suffix. You also add information if you move the files. Or store the filenames in some database table. I don't know if Mirth has an internal feature that tracks which HL7 messages it already processed, but if such a feature exists, the keyword 'deduplication' might be associated with it.

Is there a clever way to pass a yml locale file to my client for translation?

I have finished a rails project using i18n and now I need to pass all the text in the website to our client so that he can translate them and we can include additional locales to our app.
The problem is our client is not a geek and if we give them the actual YAML file, they will use MS Word to edit it and we'll lose all the proper markup in the process ("\n" for new lines, one line text, etc...).
How would you handle this process?
Is there a better way than giving the client a .doc file and then loosing a day to clean the text afterwards and manually converting it back to YAML?
Thanks in advance,
Augusto
This is exactly what Locale was created for : you upload your YAML files, your client/translator edits the content and you sync YAML back down. You don't email files and you don't have to deal with crappy file formats - check it out!
Full disclosure : I co-founded and develop Locale.
This sounds like a one-off thing where I you do the translation once and then be done with it.
What we do in these cases (we usually work with a Translator for these kinds of things) is that we export all the keys in the YAML to Excel and send them that.
Once we get it back we usually task a intern with fixing up the yaml (after it's been translated back into YAML - we do this manually at the moment but a little script should be easy to implement)
Other solutions could be (if you do this a lot) that you include the translations into your app and enable through some JavaScript and maybe something similar to Aloha Editor the user to simply click on texts and translate them in the app. But that's a bit excessive and only makes sense if there are really a lot of translations to be done and you want to crowdsource them (Facebook did this back in the day)

File repository in ruby on rails

I would like to create a simple file repository in Ruby on Rails. Users have their accounts, and after one logs in they can upload a file or download files previously uploaded.
The issue here is the security. Files should be safe and not available to anyone but the owners.
Where, in which folder, should I store the files, to make them as safe as possible?
Does it make sense, to rename the uploaded files, store the names in a database and restore them when needed? This might help avoid name conflicts, though I'm not sure if it's a good idea.
Should the files be stored all in one folder, or should they be somewhat divided?
rename the files, for one reason, because you have no way to know if today's file "test" is supposed to replace last week's "test" or not (perhaps the user had them in different directories)
give each user their own directory, this prevents performance problems and makes it easy to migrate, archive, or delete a single user
put metadata in the database and files in the file system
look out for code injection via file name
This is an interesting question. Depending on the level of security you want to apply I would recommend the following:
Choose a folder that is only accessible by your app server (if you chose to store in the FS)
I would always recommend to rename the files to a random generated hash (or incremntally generated name like used in URL shorteners, see the open source implementation of rubyurl). However, I wouldn't store them in a database because filesystems are built for handling files, so let it do the job. You should store the meta data in the database to be able to set the right file name when the user downloads the file.
You should partition the files among multiple folders. This gives you multiple advantages. First, filesystems are not built to handle millions of files in a single folder. If you have operations that try to get all files from a folder this takes significantly more time. If you obfuscate the original file name you could create one directory for each letter in the filename and would get a fairly good distributed number of files per directory.
One last thing to consider is the possible collision of file names. A user should not be able to guess a filename from another user. So you might need some additional checks here.
Depending on the level of security you want to achieve you can apply more and more patterns.
Just don't save the files in the public folder and create a controller that will send the files.
How you want to organise from that point on is your choice. You could make a sub folder per user. There is no need to rename from a security point of view, but do try to cleanup the filename, spaces and non ascii characters make things harder.
For simple cases (where you don't want to distribute the file store):
Store the files in the tmp directory. DON'T store them in public. Then only expose these files via a route and controller where you do the authentication/authorisation checks.
I don't see any reason to rename the files; you can separate them out into sub directories based on the user ID. But if you want to allow the uploading of files with the same name then you may need to generate a unique hash or something for each file's name.
See above. You can partition them any way you see fit. But I would definitely recommend partitioning them and not lumping them in one directory.

How to manage translations as they are added by release?

I work on a RoR website that is translated into a number of languages. It's a real pain to manage the "what's new to translate" for each release. We have to collect all the new keys and send them out in a spreadsheet to the translation team. So, my question is:
How do people structure their locales files and manage the addition of new keys so that it's easy and painless to communicate changes to the translation team?
http://www.github.com/mynewsdesk/translate
This is really awesome though won't organise your languages translation yml's into any particular categorised structure. It will insert the word "missing" however, where necessary and remove orphaned entries.
You might also wish to look at the textmate bundle.
I wrote a gem to solve the "what's new to translate problem"
https://github.com/zoodles/vocab
After you install the gem, you run the following command:
vocab init
This will save a reference to the current git master SHA to a file called .vocab
After adding strings to the site, you run:
vocab extract rails
This will generate a yml file containing all the english keys and strings that have been added since the commit represented by the SHA in .vocab. You can send this file to translators for translation.
When the translations come back from translators, you can run the command:
vocab merge rails
This will put the translated values in all the correct yml files under config/locales.
We recently switched to https://webtranslateit.com/. A great tool for managing our locales. Just push up the latest master locale yml file to their web service and it will flag all new string as untranslated and it even track changes on old strings and mark them as "Need Verification".
My colleague wrote a blog post about our translation workflow for a couple of days ago.
I would suggest some simple ways. We follow the first one -
Always maintain the entries in the locale files sorted on the key. This will help you to find out the extras/missing by doing a simple diff using any diff tool
Put a marker at the end of file after previous release and add new key-values at the end of the file
Easy actually... The best thing to do is to send the translation team your complete English language file. If they are professionals, they are using a translation memory tool such as Trados or Deja Vu. THey will import your file and the strings that they already translated will pre-populate, and they will be left with only the delta.

Resources