As you probably noticed, you cannot change the text of the buttons of the camera dinamically, instead you need to provide a language code to change the text of the buttons (that once again are fixed).
This happens because the labelConfirm and labelRetry native methods of the library expects as argument the ID of an element in the resources. And till the date, you cannot manipulate a resource file dynamically.
Change the text of the buttons
You will need to modify the strings_materialcamera.xml
file in the plugin (either from the plugins folder of your project or fork the repository and then add it as a plugin) e.g to change the text of spanish:
<string name="label_retry_es">Repetir</string>
<string name="label_confirm_es">Confirmar</string>
Just change the content of the tag:
<string name="label_retry_es">Reintentar</string>
<string name="label_confirm_es">Usar</string>
And you're ready to go.
Add a new language
You can add a new language without messing up the Java Code, the only thing you need to do is to modify the strings_materialcamera.xml
and add 2 new tags with the format label_retry_XX
and label_confirm_XX
. The XX
stands for the new language code, this code shouldn't exists, if it's a new version of the same language please add some suffix as es_co
:
<string name="label_retry_imaginarylang">OQWIUEQWE</string>
<string name="label_confirm_imaginarylang">ASDLKQAS</string>
Then to use it, provide the new language code in Javascript with the setLanguage
method:
OurCodeWorld.MaterialCamera.camera
.setLanguage("imaginarylang")// Set the buttons to imaginarylang
.startCamera({
success: function(e){
console.log(e);
}
});
If you know a language that isn't implemented in the library, please make a pull request in case you can.