SetActivityAttribute("main", android:label, "@string/app_name")
SetActivityAttribute("main", android:configChanges, "locale")
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetActivityAttribute("main", android:label, "@string/app_name")
SetActivityAttribute("main", android:configChanges, "locale")
'End of default text.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Label to display</string>
</resources>
I did some research and found out how to change the label of the application when you change the language in the device settings.
In the manifest, insert the line:
B4X:SetActivityAttribute("main", android:label, "@string/app_name") SetActivityAttribute("main", android:configChanges, "locale")
Manifest:
B4X:'This code will be applied to the manifest file during compilation. 'You do not need to modify it in most cases. 'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136 AddManifestText( <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/> <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/>) SetApplicationAttribute(android:icon, "@drawable/icon") SetActivityAttribute("main", android:label, "@string/app_name") SetActivityAttribute("main", android:configChanges, "locale") 'End of default text.
Then, in folder "Objects\res" create folders for languages, like this:
"values-de"
"values-en"
"values-fr"
"values-it"
"values-nl"
etc...
if you do not expect some languages, for default settings, insert a folder named "values".
In each folder insert an xml file, named "strings.xml" with this content:
B4X:<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Label to display</string> </resources>
Change the string "Label to display" with the translated one.
Make all folder and file Read Only because b4a will delete!
cb56
E 'can also translate the text of a button, edittex, listview etc?
If the answer is yes, please make me an example for these three?
AddManifestText(
<uses-sdk android:minSdkVersion="4"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetActivityAttribute("Main", android:label, "@string/app_name")
SetActivityAttribute("Main", android:configChanges, "locale")
Can you upload one of these files?
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" formatted="false">ñññ</string>
</resources>
B4A version: 5.80
Parsing code. (0.00s)
Running custom action. (0.32s)
Compiling code. (0.04s)
Compiling layouts code. (0.00s)
Generating R file. Error
AndroidManifest.xml:14: error: Error: No resource found that matches the given name (at 'label' with value '@strings/app_name').
AndroidManifest.xml:17: error: Error: No resource found that matches the given name (at 'label' with value '@strings/app_name').
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Test App</string>
</resources>
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "@string/app_name")
'End of default text.
CreateResource(values, strings.xml,
<resources>
<string name="app_name">Test App</string>
</resources>
)
Is your #ApplicationLabel set to @string/app_name ?Thanks Erel. I had not thought to use that new feature. Unfortunately though, it still is not working. Using the above manifest code in a brand new project gives the results of the following. The #ApplicationLabel attribute somehow overrides what is specified in the manifest editor above. If I delete the #ApplicationLabel line in the project, the app label changes back the B4A Example.