-2

So question is how to calculate percentage of translated text in strings.xml from values-(lang) against values (default language).

I know how to access string from resources but there is no option to set language code. I found some answer with changing locale but I'm "scared" of blinking UI with another language even for few ms.

Plan will be that I will count strings in default language /values/ and count also in /values-(userlang)/ and if percentage will be lower than for example 90% I will ask user (someone who uses my app often and longer time) for help with translation.

Don't need full function, just safe method to access strings (in loop) from other locale without changing user locale.

There is no goal to do it manualy. Making manually diff is no way.

So I have made a solution Custom made class, but I guess by my rating that nobody will appreciate it, so just result what I was looking for:

myTranslationRatio=new TranslationRatio(context,"en",deviceLang);

Log.d("my","myTranslationRatio getLangCore: "+myTranslationRatio.getLangCore());
Log.d("my","myTranslationRatio getLangCurrent: "+myTranslationRatio.getLangCurrent());
Log.d("my","myTranslationRatio getTranslatedRatio: "+myTranslationRatio.getTranslatedRatio());
Log.d("my","myTranslationRatio getCountCore: "+myTranslationRatio.getCountCore());
Log.d("my","myTranslationRatio getCountCurrent: "+myTranslationRatio.getCountCurrent());
Log.d("my","myTranslationRatio getCountToTranslate: "+myTranslationRatio.getCountToTranslate());

result

: myTranslationRatio getLangCore: en
: myTranslationRatio getLangCurrent: cs
: myTranslationRatio getTranslatedRatio: 0.972973
: myTranslationRatio getCountCore: 148
: myTranslationRatio getCountCurrent: 144
: myTranslationRatio getCountToTranslate: 4
Adam
  • 130
  • 1
  • 2
  • 12

1 Answers1

0

As for setting the language code programmatically, you can review this question. Really make sure to read the comments as there are important points made there.

Assuming updates to your strings.xml file is done statically via app updates, then my first instinct would be to copy your existing strings.xml into your new language folder and try to use diff to keep track of how much is done.

Community
  • 1
  • 1
Kris
  • 321
  • 1
  • 6
  • 13
  • I don't want to change language of the app, you answer is totally off topic. – Adam Sep 08 '16 at 06:38
  • @Adam the first part of my answer is in Java while the second part of my answer refers to command-line tools. I don't see how requires changing the language the app is written in? In your post you directly mention changing the language of your app – Kris Sep 08 '16 at 07:10
  • Yes, I mention it but I wrote that I DON'T want to change language. Really DON'T. – Adam Sep 08 '16 at 08:36
  • @Adam I think you need to edit your question for clarity. You are currently asking how to calculate a ratio of statically defined items. – Kris Sep 08 '16 at 08:43
  • Question is just fine. – Adam Sep 08 '16 at 09:22