I have an app with several translations, and I want to delete some strings.
How can I refactor and delete them only once for example in the default strings.xml file and automatically propagate the deletion to the other strings.xml file of other translations?
You can remove all translations by "Translations Editor" in Android Studio.
Select string's key
Click on "Remove key" button
Uncheck all checkboxes in "Delete" dialog
Click "OK" button in "Delete" dialog
CTRL-H
select tab File Search
check regular expression
input \R\s*<string name="string_name">(.|\R)*?</string> and
don't forget replace string_name to actual string name.
file name patterns set *.xml
Press Replace...
Leave replace field empty.
Press Preview >
Check all replacement.
Apply changes by press `Ok'
default strings.xml file and automatically propagate the deletion to the other strings.xml file of other translations
ADT does not support this operation. You need to get rid of the text from all your XML files yourself, which should not be hard task anyway, as it would be sufficient to do project global search (in Eclipse CTRL-H), set file mask to *.xml and search for your string key. Then just remove this file from each file found.
Now you can do it easily with Translations Editor.
To open it click on the Open editor on the top right corner in xml file.
Then in the editor right click on key you are want to delete and press Delete Keys(s)
This is the way that I have done to Delete a language I do not want.
1: Make a backup copy of your project.zip
2:Go to Your project folder >app>src>main>res:
In this folder, you will find all languages in the form of folders
Remove the language folder that you not want For example : values-ar-rSA
back to android studio clean your project and test
Related
I'm trying to translate a strings.xml file on Android Studio but it seems like the Translations Editor is not enabled (it does not appear as an option when I right click on the strings.xml file). I've tried deleting and installing back Android Studio but it's still the same; any ideas on how to solve?
Thank you in advance!
this is the "no enabled action found message I get
you have to open the string.xml file, then you will see the open editor option on the upper right side
Reopen the Android Studio IDE, it'll solve the problem. Also it will update the strings and refresh the layout of any layout xml.
Translations Editor shows up when you right-click on string resource files whose names end with strings.xml. On others it does not. The same goes for editor option that is supposed to show up in upper right side when string resource file is opened.
So, filenames like strings.xml, preferences_strings.xml, etc. are fine, while strings_intro.xml, etc. are not.
In case you don't have any string resource files named in that way, you can create an empty one named strings.xml and use it to open Translations Editor.
Or, you can open the it in the following way:
Open any xml layout file
Switch to 'Design' view in upper right corner
Design toolbar will look something like the following:
Click on the localizations option (globe icon)
At the bottom of the drop-down menu you will see 'Edit Translations...' option
Click on it - and there you are!
I want to know how to remove unused languages from application with Android Studio, like French or German (unused Languages for me). I only need English and Arabic.
From Developer Documentation here
To delete a language, do the following:
You can delete a language in the Translations Editor by deleting every value in the column (see Edit, add, or delete text), or you can delete the project folder for that language, as follows:
In the Project > Android panel on the left, select ModuleName > res.
Right click the values-* folder for the language you want to delete. For example, values-hi for Hindi or strings.xml (in).
From the drop-down list, select Delete to delete the folder and its strings.xml file.
There is an easy way to do this now:
Open Translations Editor (double Shift and Open Translations Editor)
Right click the desired column and select Remove Locale
I cannot figure out how to search for text inside an individual XML file from Eclipse. Basically if I am editing one of my xml layout files, and I hit CTL + H -> file search -> Selected resources radio button checked, I always get '0 results in empty scope' as my results. Google hasn`t given me any help on this.
My workaround is to choose 'Workspace' instead of 'Selected resources' and then navigate to the file I want in my search results which is time-consuming. Why doesn't eclipse recognize my current XML file as a selected resource like it does with java files? Has anyone else had this issue? I`m using Eclipse ADT 23.0.2.129578
Go to the Source tab of the layout file editor, then use Ctrl+F to open the Find/Replace dialog. You can also use Ctrl+K to traverse through matches of the last search, even when the Find/Replace dialog is closed.
You can use Ctrl + Shift + R for searching the XML file quickly in eclipse.
I am only getting autocomplete in my xml layout when i type "android:" I want to get it whenever I press cmd+space. I am using a mac
Go to
Eclipse -> Preferences -> XML -> XML Files - > Editor -> Content Assist
and tick all proposals checkboxes to allow this.
EDIT : Also tick Automatically make suggestions and Insert single proposals automatically checkboxes.
Open Preferences and in the search type XML, you would find on the left pane a XML hierarchy and under editor you will have content assist. Just tick all the boxes there are in this page and you are good to go!
Window--->Preferences----->General------->Keys, find Content Assist and set attribute Binding as cmd + space, and attribute When as Editing in Structured Text Editors, if it still not work, right click on your xml file, choose open with, try to use Android Menu Editor. Good luck.
I found the solution:
I needed to unselect in my mac SystemPref --> keyboard-->shortcuts there was a command "select the previous input source"
All You want is code promption whatever you enter.
Eclipse -> Preferences -> XML -> XML Files - > Editor -> Content Assist
Then input "prompt when these characters are inserted" with
#+<=:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
I am seeing a strange problem with my Eclipse IDE for Android development.
Autocompletion does not work when I hit Ctrl + Space in the main.xml file for my layouts. In the bottom left, I get a message saying for example "LinearLayout not found".
I also have the correct namespace specified in my file.
It does work though for other xml files, such as my strings.xml which I find strange.
This is an annoyance as I'd like to easily see all the options available for a View or Layout.
Anyone got any ideas on how to resolve this?
Check that the file is being opened in the Android XML Layout editor (not just the "plain" XML editor). Right-click the file, choose Open With, and select Android Layout Editor.
It seems like an eclipse XML editor issue.
If you declare the xmlns in other than "xmlns:android" you loose the autocompletion.
for example if you say:
xmlns:android="http://schemas.android.com/apk/res/android"
android:.... //AUTOCOMPLETES
if you say
xmlns:android1="http://schemas.android.com/apk/res/android"
android1:... //DOES NOT AUTOCOMPLETE
Open eclipse and go to the following:
Window > preferences > XML > editor > content assist > advanced
Select all checkboxes and click ok. After that, restart eclipse.
Try this as suggested powder366
Or you can set the default editor in Eclipse Preferences, used Android Common XML Editor. You find it in Eclipse Preferences, General, Editors, File Associations. Click on .xml, choose "Add" "Android Common XML Editor". Select it and press the Default button.
OPEN YOUR FILE WITH GENERIC TEXT EDITOR
Right-click on XML File, select Open with GENERIC TEXT EDITOR
Check that the file is being opened in the Generic text editor.If not then, Right-click the file, choose Open With, and select Generic text Editor.