Change language firebase_ui_auth using strings.xml - android

I am trying to change the language of my flutter application that uses the firebase_ui_auth library
I added the resConfigs parameter 'es' in the build.gradle file and created the values-en folder but it doesn't work.
SC:

First, please don't put the full git repository into a question - it contains sensitive information and keys please avoid this ... please try to put a problem code snippet.
Stackoverflow is not responsible for your security - is someone debugging your code with your all information?

Related

android app/business-logic config

how does an app developer store app-specific (ie. my server addresses, path endpoints, etc.) global and build variant specific config values in an android app? further, is it possible to have overrides? ie. i want to set a default value in my global.config, but collisions in staging-build-variant.config and prod-build-variant.config should override this, while dev-build-variant.config would simply use the default value.
i've read about SharedPreferences but this seems for storing user input at runtime for later runs, and i've read about people using a class to hold constants, but that doesn't quite fit either as i don't get any benefit of a specific configuration values overriding common ones. there is also a lot of seemingly outdated articles out there which i'm not sure are accurate anymore.
i asked this as a comment in this question which seems to be close to what i'm looking for, but thought i'd ask as a question for more exposure.
EDIT: maybe i explained this poorly - to clarify, this comment.
Justin, it seems that what you whant is a library project. You will have to create a library project with one default configuration.
Let's say that project is called Core and then it has the following strings.xml:
<string name="server_address">htt://path.to.server</string>
This way you can create a module (called app1) for the project that uses the 'Core' library project. Then you will end with two strings.xml file.
So the strings.xml file from your app module will override the strings.xml from the library project. Then you can have:
<string name="server_address">htt://app1.path.to.server</string>
Resources:
Create a library Project
[UPDATED]
Instead of use a library you can try a grade variable. See this question:
Gradle Variables
And this link about build variants:
Build variants

How do I remove unused languages from the final APK file with Xamarin.Android?

I've added some of the Android support libraries to my project and now I'm basically facing the same problem as described in this question:
Android Studio exports strings from support library to APK
Since I can't use Gradle settings with Xamarin, I can't use the solution described in the StackOverflow answer.
Does anyone have an idea, how I can keep only specific localization in my final APK file?
Generally, in Xamarin, The AndroidManifest handles special instructions for uses of libraries The Android.App.UsesLibraryAttribute(string name, bool required) sets specific inclusions and exclusion that will be in the generated Manifest.XML.
Also as far as I know there are only three ways to set link exclusions, the first and second are mentioned by #sunseeker, however Xamarin documentation and dev notes strongly recommend not using Full as indicated above and in general advocate using the following:
SdkOnly(default)
the second also mentioned above is for specific exclusions, it is also recommended not using this unless you are sure a particular package is not getting called "behind the scenes" by an extended class further up in the hierarchy.
Finally in the third method is to set LinkMode to None, while specific linkings are stipulated using the AndroidManifest interface.
Some other ways to get efficiencies are to:
set AndroidUseSharedRuntime property to true at least while debugging to reduce package size.
set AotAssemblies property to true when you have a stable build to precompile the libraries that are included.
set EmbedAssembliesIntoApk to false unless it is a release build.
That's about as far build knowledge goes with Xamarin, hope it helps.
Can't really check it now, but have you had a look at AndroidLinkSkip and AndroidLinkMode (reference) tags in a solution .csproj file?
So, it'd be something like
<AndroidLinkMode>Full</AndroidLinkMode>
<AndroidLinkSkip>Mono.Android.Export;I18N;I18N.West</AndroidLinkSkip>
Also, have a look at MandroidI18n. From the same reference above:
Specifies the internationalization support included with the
Application, such as collation and sorting tables. The value is a
comma- or semicolon-separated list of one or more of the
case-insensitive values
<MandroidExtraArgs>-i18n=west</MandroidExtraArgs>
or
<MandroidI18n>West</MandroidI18n>
So I've finally managed to do this in a sane way
Download Apktool from https://ibotpeaches.github.io/Apktool/
Create your final .apk with Xamarin and decompile it with apktool d MyApp.apk
Go into the MyApp directory that Apktool has created and look for the res directory
Remove all values directories that end with a language identifier that you don't need, e.g if your app only supports the German language, remove values-fr, values-es, etc..., but not values-de. Don't remove non-language directories, e.g values-v11!
Recompile your app with apktool b MyApp
The recompiled app package is now in MyApp/dist/MyApp.apk. Take this file and sign it with the signtool, then zipalign it.
Upload the apk to Google Play
I'm sure this process can be automated, I'll update this answer as soon as I have a script for that.
Have you tried solution from Borris Spinner:
You can provide AndroidResgenExtraArgs in your project file and add -c en,de etc.
See aapt documentation:
-c specify which configurations to include. The default is all
configurations. The value of the parameter should be a comma
separated list of configuration values. Locales should be specified
as either a language or language-region pair. Some examples:
en
port,en
port,land,en_US

Accessing strings.xml values in android library project

I have MyAppProject as android application project and MyLibProject as android library project.
I have strings.xml(2 strings) and one xyz.java class in MyLibProject.
xyz.java class has 2 get methods to access the strings.xml values.
I have added reference library project "MyLibProject" in "MyAppProject" application project.
For some usecase, I will check whether Library project xyz.java class is in classpath then get the
values from xyz.class.
How to access the strings.xml texts in xyz.java class get method?
As far as I'm aware, you should be able to access any references via a fully qualified name for the R file you're attempting to access, via the Context. Something like (untested):
Context.getString(com.YOUR.LIB.R.string.YOURSTRING));
Failing that, you could possibly import the com.YOUR.LIB.R file directly into your activity.
Hope this helps! And I hope that I understand what you're trying to achieve. If not, please provide more information and possibly some code you've already tried, may help explain your problem :)
This question has been very old, but creating Android libraries will never get old. I have been working on creating Android libraries for a few days now, and myself encountered this issue of not been able to use res directory resources in library's java files due to some reason. After 2 days of searching, I found that I was missing package declaration in my library's manifest file.
So, to make it working, check if you have declared package in manifest.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.yourpackage">
</manifest>
It worked for me after this change, now I can use resources in library's java files. I hope it works for you too.

Parse comments in XML in Android

For my personal purposes I'd like to parse comments in Android Manifest file. In these comments there can be tags with attributes and values that I want to extract. It is similar to tag in html files that is usually commented because some browsers does not support this tag. So I want to implement similar things in android manifest.
I know that in Android manifest file is parsed using SAXParser. Moreover, I think I should use LexicalHandler for this purposes but I've never faced before with this functionality and I want to know how to do this. Code snippets and any help will be highly appreciated!
I'm entirely sure that you cannot parse the raw XML Manifest, because like everything that is in the res folder (except res/raw), the manifest is compiled and stored in a binary format, so the comments are removed.
Maybe you can play with xmlns and capture the manifest parsing... But I doubt it, the Manifest is interpreted by the package manager, and I don't think that you can have access to it.
The solution (from your feedbacks):
The requested feature is impossible, because during the compilation all comments from AndroidManifest file are removed.
You can check this in the following way:
Create a simple app project (Hello World) and add comments in your AndroidManifest file.
Compile project and export an .apk file (signed or unsigned).
Using tools like apktool or similar extract your apk file.
Check the result in AndroidManifest.xml - there are no comments.
You should try to find other way.
I don't think it is possible as the AndroidManifest is not available as a classpath resource. The only way I can think of is to actually make a copy of the AndroidManifest.xml into your source files and have it built as a compiled object using an ant target
Then you just access it like a normal XML file using the XML APIs.
I hate to be that guy, but you should probably maintain your custom XML in /assets/ and not overload the manifest.xml file.

Android: Get missing translations for strings-resources

In Android, you can specify the texts in the default locale in res/values/strings.xml. Additional translations can be added for new languages in res/values-it/strings.xml (for Italian for example). If a string is not translated, the fallback-default locale is used.
Currently I can not tell which strings I still need to translate (so are in values/strings.xml, but not in values-$/strings.xml for all $ in languages) and which are translated, although the are obsolte (so are in values-$/strings.xml, but not in values/strings.xml exists $ in languages)
I'm searching for a tool which gives me the translations which are missing and the one which are obsolete.
To be honest, it is not that difficult to write such a tool for the command-line, I can only hardly believe nobody has already done this.
This isn't automated, but it's very fast. In Eclipse, to go Window->Show View->Other->Android->Resource Explorer.
Now, under the Resource Explorer tab at the bottom (or wherever you've moved it to) look under String. Each string should have the same number of versions if you have a complete translation, so you can scan down the list in just a few seconds.
Do this for each project that has strings.
I didn't know about this until after I localized, but it's still useful (such as when I add a new string).
If you are using Android Studio, it is easy to find which string is missing.
Right click on values/strings.xml
and choose Open Translations Editor:
Where you can easily find missing strings in all languages as below :
Thank You...
The new official Android Lint tool helps you detect this problem, and many others: http://tools.android.com/tips/lint
Interesting question. I've wrote simple script to find duplicate resources in android project at https://gist.github.com/1133059. It is ugly, I know, but I'll rewrite it in a few days and maybe create a project on github.
To run it from console:
$scala DuplicatesFinder.scala /path/to/android/project
UPDATE:
I've made a project on github https://github.com/4e6/android-localization-helper, maybe someone find it helpful
There's a much improved version of the Android Dev Kit lint tool in Eclipse since SDK version 17 - see the docs here: New Eclipse Lint UI
Just click the "lint" tool bar item, run it on your project then open the "is not translated" item that will appear to show you every tag that needs translation.
Credit to satur9nine - this is an updated version of their answer which lead me to this one.
You could also use Android lint (easy access from Eclipse). Right click your project -> Android Tools -> Run Lint. This will give you a list of all missing translations, and also some other common errors.
It will also show you duplicate resources and strings not available in the default translation.
On Android Studio, Analyze > Run Inspection By Name, Type following and execute inspections for Custom scope Project Production Files.
Extra translation
Incomplete translation
I created a tool to solve precisely this problem. You can download the tool from https://github.com/vijtheveg/tea.
The tool can generate an Excel spreadsheet from the Android project, like the one shown below, with the source strings and their translations shown side-by-side.
Most importantly, the tool will output only those strings that were newly added or modified since the last translation!
You can send this Excel spreadsheet to your translator and once the translations are filled in, you can regenerate the string XML files for the target language from this Excel file.
Best of all, you can perform this process (add/delete/modify strings in the source language XML files) -> (generate Excel and send it for translation) -> (regenerate target language XML files) any number of times, and each time the tool will only output those strings that need translation into the Excel file. The tool will also delete strings that have been removed from the source language from the target language XML files.
More details on the tool's GitHub page above. I hope you find it useful.
I'm the Product Manager for MOTODEV Studio. As #hjw mentioned, this is a feature of MOTODEV Studio called the "Localization Files Editor". This editor is similar to a spreadsheet and lets you see all your strings in one view. You can edit as a spreadsheet or the underlying XML in the same view.
MOTODEV Studio is a branded version of Eclipse, so it should work with your existing projects if you use Eclipse. If you prefer to continue using your existing Eclipse setup, you can still use MOTODEV Studio to handle the editing of the string.xml files, just so long as only one version can have the workspace open at a time.
If you have any questions about how to use it, feel free to send me a message or post on our discussion boards at developer.motorola.com
There is none which I am aware, I am favouriting the question. :) However as a best practice, I first complete the default strings.xml and translate it in the very end. I also add a small marker comment to specify end of translation and any new strings are added below that. This helps me keep track of ones which are not translated.
-- UPDATE --
With latest ADT tool for eclipse you can install Lint which takes care of all the issues regarding duplicates and a lot more with its exhaustive set of warnings.
If you're willing to use the getlocalization.com web site, which is free of charge if you're willing to have your translators work on your localization publicly (otherwise, you have to pay to make your project private).
You can just use their Eclipse plugin, to automatically import the strings from your Android project:
http://getlocalization.github.io/eclipse/
Then this is the interface your translators will see when they do the actual translation:
I recommend you right-click on the screenshot above to view it in a larger format on a separate tab. It's actually well thought out and should make the translator's job easier too.
Steps to get all missing translations are :
enable lint error for missing translation in app level build.gradle
lintOptions {
abortOnError false
enable 'MissingTranslation'
}
add languages to compare inside default config of level.gradle (here english and hindi)
resConfigs "en", "hi"
right click on default strings.xml. Then Analyze -> Inspect Code
now check inspection result. Android -> Lint -> Correctness -> Messages > Incomplete Translation
All selected strings are missing translations
Do you know MotoDev Studio for Android? It features a localization tool. Within that tool all langauges are columns and all texts are rows. It's very easy to find missing translations within that "spreadsheet". The other way, find obsolet translations, is not that easy.
I suggest Amanuens that let you easily identify untranslated strings and strings that not match in master and translated files. It can, optionally, be configured to automatically keep translation files synchronized with the repository. You can also give your translators access to the service and they can find an easy to use web editor to translate your application.
I built a command line tool called ams (for android-missing-strings) that prints a report of every missing entry as well as leftover entries that no longer appear on your base strings.xml file.
It's available here
https://github.com/gubatron/android-missing-strings
ams - Android Missing Strings reporting tool.
Usage:
ams [-l xx[,yy,zz...]] -o <output_file>
Options:
-h --help Print this help
-l --lang <xx> Specify a language or many with comma separated 2-char language codes.
e.g: -l cn (creates report for Chinese strings.xml)
-l cn,it,fr (creates report for Chinese, Italian and French strings.xml files)
If this parameter is ommited, a report with every language file found will be created.
-o --oFile Specify the output file name for the report
Copyright (c) 2014 - The Mit License (MIT)
Authors:
Angel Leon <gubatron#gmail.com>
Katay Santos <kataysantos#gmail.com>
If you also want to let other people contribute and have a web site you can use the open source TranslateApp-tool.
It keeps track of what is translated and not, you can also update the default language and say if translations should be invalidated of not.
https://bitbucket.org/erik_melkersson/translateapp
Note: I am the author of the tool. Pull requests with updates are welcome. I actively use the tool myself.

Categories

Resources