“is translated here but not found in default locale” error in strings.xml with translatable=“false”

点点圈 提交于 2019-11-29 04:27:26

问题


Here is my values\strings.xml (the default file) and everything is self explanatory:

My question(s):

  1. How can it be "not found in default locale" if I am editing the default locale (values\strings.xml)?
  2. How can it be a lint translation error if I set translatable="false"? In the values-pl\strings.xml (and values-ru, values-iw folders as well) the strings don't exist even? it shouldn't anyway.
  3. I can't seem to understand why I don't get the error for the Russian string.

(I would show the values-ru\string.xml or values-pl\string.xml here but there is nothing there of interest, since the strings are missing anyway...)


回答1:


this happened to me too

I do 2 things:

  • Verify entire file to see another translate not done ( I have ones in file en but in pt-br)
  • Clean, update gradle and quit and restart the Android Studio



回答2:


Rebuilding can take a long time. YMMV, but...

Simply remove the offending line and re-add it.

Worked for me. Very fast.




回答3:


In my case this helped me:

  1. Select the strings that cause error.
  2. Cut them.
  3. Paste them again

If it doesn't work for you, try adding the same strings to strings.xml(v21) file.




回答4:


Press Invalidate Caches / Restart ... to restart android studio. It worked for me. Actually this happened when I had copied files from my other computer and pasted via file explorer.




回答5:


I had the same error message, just with the weird issue that it was thrown in the default locale itself and all translations. Turns out you should not use dots in your name (e.g. name="bla.blub") because it will be internally converted to "bla_blub" and then it cannot match with "bla.blub", hence the error. I only had to change the dots to underlines in the default locale and then all other errors in other translations (including dots in the name) were gone as well.

But be aware that other build tools can still create issues, so replace all the dots with underlines instead!




回答6:


Quitting Android Studio and restarting it fixed it for me.




回答7:


I've created a tool to manage the translation status of android apps. It not only tells you what strings are missing on the other languages, but it can also report, and clean the left over strings that you may have deleted on your default translation file.

https://github.com/gubatron/android-missing-strings

To clean all left overs in other languages invoke like this

./ams --cleanleftovers -o all.txt

This will clean the left over strings and it will output the missing strings report for all the languages into the all.txt file




回答8:


I solved this issue by following below steps:

  1. cleaning my project

  2. rebuilding it

  3. and finally pressing invalid caches/ Restart in file menu

I hope it could help anyone who faces this issue in Android Studio.




回答9:


"xmlns:tools="http://schemas.android.com/tools" You should add this code to the resources tag of file strings.xml




回答10:


Just make sure that you have same naming conventions on all strings files including the same capitalization. let's say if you have "sign_in" in strings.xml and "sign_In" in your fr/string.xml, so it will give you error on fr/strings.xml like "is translated here but not found in default locale". So, when you edit to "sign_in". The error will remove.




回答11:


You simply just have to copy the offending line (or just one of the multiple of offending lines), remove it, and re-paste it. That removed the issue for me.



来源:https://stackoverflow.com/questions/50027691/is-translated-here-but-not-found-in-default-locale-error-in-strings-xml-with-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!