How to do spell-checking throughout my project in android studio - android

I am spell checking my project which is developed with android studio. I have multiple files to check spelling. I mean multiple string resource files and a few layouts(I know its a bad practive to have strings directly in layout, but had a little usage and previously developed).
Is there a way to find the find only the misspelled words? (like we do
find a word in whole project). I searched a lot and didnt find any solution.
thanks in advance
Note : My project is developed only for English. I don't use any other languages

If I understood you correctly, then you want to find the words, that you misspelled (write incorrectly) in your project.
To do this you can:
In main menu of Android Studio: Analyze - Inspect code - select Whole project - click OK
In the analyse results find Spelling
Inside it there will typically be 1 sub-item - Typo
Inside it you will find all found possible typos (misspelling) over the project including method\variable names as well as typos in the string resources.
String resource typos can be found under the module name folders.

Related

How to find all String literal in my android project and move it to strings.xml file

I'm currently working on the Android project. I'm mostly put all the string literals in strings.xml file. But in few cases, I directly inserted few strings in Java file directly.
Now, I want to give multilingual support for my project. So, that I have to find all string literal in my android project and want to move it to strings.xml. The manual process was too much time-consuming. Any other easy way to achieve this task in Android studio?
You can achieve it like this:
Go to >Analyze>Inspect code e click ok on the pop up, after a few minutes, inspection results will be visible, and you should find hardcoded strings under "Android>Lint>Internationalization-Hardcoded text"

How to detect resource variable typos in Android Studio (ex: "%1$ s")

Android crashes are often caused by a resource containing %1$ s when %1$s was intended.
To my surprise, Android Studio does not show these syntax errors:
↑ The real syntax error above is the %1$ s (makes the app crash), not the ellipsis that Android Studio highlights.
How to check for resource variable typos in Android Studio?
I am looking for the equivalent of lint --check StringFormatInvalid.
Context: Many semi-automatic language translation tools break variables, making apps crash.
What I have tried, does not work:
in Intellij it is possible to create custom inspections. I am not sure if it is possible in Android Studio.
Follow the link:
https://www.jetbrains.com/idea/help/creating-custom-inspections.html
edit:
after follow the steps in the link you see in the next image my created inspection:
In the next image you see the basic configuration of the inspection:
In the next two images you see the setting of the variables.
Only the used regex is not the ready. You must write it for general variable using (between $ and . is a space):
Every thing in strings.xml between <string> and </string> is merely a string for Android studio and lint. It will not identify syntax typos. Syntax errors/typos means error with code and not strings. You'll need to make sure that these are written right by yourself or create your own script to do these checks on the string.xml file. There is no inbuilt mechanism to identify code in strings and then check for syntax errors in them.
The highlighted thing with ellipses is there because it is a grammatical (optimization) error. If you make a spelling/grammatical mistake in strings.xml it will be highlighted. Example below:
But, if you intend to put in formats/code as strings it needs to be handled on your own or using some custom script that you'll need to write by yourself. Or as mentioned by #Rüdiger in his comment on the question, you can write unit test cases to check the sanity and integrity of your strings in strings.xml.

Translating and adding a language to Android 'Language & input' menu

I would be really grateful if anyone could help me out on this.
I've put a lot of time into translating the main Strings.xml files (e.g the ones found in packages/apps/Settings/res/values) into Welsh. I've tested them by replacing the Strings.xml file in the values-en-rGB folder. The next step (which I am really stuck on) is having Welsh appear as an option in the 'Language & input' menu.
I've created a values-cy-rGB folder according the the ISO naming convention, but I can't find where I should associate this with Welsh (Cymraeg). I would have thought there would be a reference somewhere which lists which languages appear in the menu and points the system towards the correct folder extensions? I've read up on locales but I can't seem to find any info on translating the Android system itself; only info on translating apps.
I'm compiling KitKat 4.4.2 r_1 on ubuntu and testing using the emulator.
Many thanks
Sion

Android add new image gives error

This might seems silly but seriously I don't even know why it reacts that way. I am using eclipse JUNO, and I just trying out simple program enables me to put an image inside the layout after my real program said it have the error.
The project shows the error icon but when looking all in the subs-project like the class, layout everything, it is crystal clear. You can see it like the picture above.
I have making an android project before I am updating the adt and stuff. Before this, all I do just put any picture(s) I want in any folder drawable. I believe this is the right step and I know I do the same thing in here but it have issue with it. I even search on the basic tutorial how to put the image and it did the same why I did.
Does anyone knows what had happen here?
Android dont allow image names to contain capital letters in drawable folder change the name to contain only small letters
Capital letters , and some symbols are not allowed to be in the name of the png file , update the name of the png file , . make it in smaall letters
As per user inazaruk's answer, Hence the reason for not using special characters inside file names, as they can no be used in Java names.
As for capital letters, I guess that's to avoid one little problem in Windows vs. Linux environment. That's because Linux thinks that Icon.png and icon.png are different files, and Windows thinks that Icon.png and icon.png is the same file. So anyone using Linux can create application that is not compilable on Windows.
So, change your Humanpng with human Also don't use the extension png as picture name.
Just check your Problems tab in Eclipse. You can find it from
Window > Show View > Problems.
There you can find the error description.

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