The following two code snippets were added to ngenstrings so that once the text has been extracted from TweetStation, it is automatically translated and written to
.strings
files ready for inclusion in the correctly-named .lproj
folders (this code hasn't been committed to github - but it should be easy to add to your local copy).add code to the end of
MainClass.Main
string[] languages = new string[]{"fr","ja","it","de"}; foreach (var language in languages) { foreach (var table in tables.Values) { foreach (LocalizedString locstring in table.Values) { locstring.Value = Translate(locstring.Key, language); } table.WriteStringsFile(assemblyName, outputFormat, language); } }
add method to
MainClass
//http://msdn.microsoft.com/en-us/library/ff512421.aspx static string Translate (string text, string toLanguageCode) { string appId = "REGISTER_AND_INSERT_YOUR_APPID"; string translation = text; text = text.Replace(" ", "%20").Replace("&", "").Replace("#","%3F"); string detectUri = "http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=" + appId + "&text=" + text + "&from=en&to=" + toLanguageCode; Console.WriteLine(detectUri); try { System.Net.HttpWebRequest httpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(detectUri); System.Net.WebResponse resp = httpWebRequest.GetResponse(); Stream strm = resp.GetResponseStream(); StreamReader reader = new System.IO.StreamReader(strm); translation = reader.ReadToEnd(); } catch (Exception e) { Console.Write("Translation failed for " + text + " - " + e.Message); } return translation; }
Hopefully that gives you some ideas (or inspiration) on how to increase the market for your apps across the world. Remember that machine-translation is NOT a substitute for a professional human translation, however it can be useful to test your application's ability to handle and display different languages (eg. the size of the strings, etc).
Looking at the screenshots, the "Friends" text has apparently not been translated (while you did translate it for the Spanish translation).
ReplyDeleteYeah - I realised too late that I was running ngenstrings against an old build of TweetStation (where some strings weren't wrapped in the L10n method). Already taken all the screenshots so I just posted them (getting late!).
ReplyDeleteDoes ngenstrings cope with the case where I already have done some translations and I just want to update the translation strings?
ReplyDeletemdi, ngenstrings is pretty "dumb" at the moment - it just generates a new 'complete set' every time. It does output them in alphabetical order, so theoretically a file-compare tool could help you identify new Keys.
ReplyDeleteI am considering a merge/update function, either in ngenstrings itself or else in a seperate lightweight editor.
Craig,
ReplyDeleteI figured out how to do it, check out my Makefile in tweetstation/
Thanks for all of your tips, TweetStation is now translated into Spanish officially ;-)
ReplyDeleteThat's cool mdi - de nada
ReplyDeleteAll the best for your next "big release" in conjunction with ldi ;)
Craig, if you need a good l10n tool to translate iOS apps, I suggest you check out the software localization platform https://poeditor.com/
ReplyDeleteIt has a slick translation management interface which you can also use to crowdsource translations (see the public projects option). I think it's a great resource for localizing .strings file.