Android plurals not working properly when you change system language

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Android plurals not working properly when you change system language



My application has only polish strings, it's default language of an app.
Here you can see example plurals placed under res/vaules:


<plurals name="number_of_vouchers">
<item quantity="one">%d kupon</item>
<item quantity="few">%d kupony</item>
<item quantity="many">%d kuponów</item>
<item quantity="other">%d kuponów</item>
</plurals>



Here you have test activity class:


class DevTest : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_dev_test)

val stb = StringBuilder()
for (j in 1..30) {
stb.append(resources.getQuantityString(R.plurals.number_of_vouchers, j, j) + "n")
}
testTV.text = stb.toString()
}
}



This how example test looks like on system settings with Polish language set as default:
enter image description here



This how example test looks like on system settings with English language set as default:
enter image description here



You can see that for English system language it's omits


<item quantity="few">%d kupony</item>



even if app has only one language, and it's not English.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results