Translations editor not enabled in Android Studio - android

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!

Related

How to know where a string in strings.xml is used

As a user of Android Studio, I'd like to know where a string in strings.xml is used because I want to remove the strings which aren't in use.
Right click on a string in your strings.xml-> click "Find Usages" to see where it's used.
If it's not used anywhere then a little dialog will pop up in the corner saying so.
Easier way to find unused strings in Strings.xml is to launch an inspection code from top menu of Android Studio (Analyse/Inspect code) on whole project.
In the inspection window, go to "Android Lint/Unused ressources", there you will find all the unused strings.
It will avoid you to make "find Usages" for lot of strings !

Remove a string in all the languages Android

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

Eclipse is missing Graphical Layout and Source tabs when editing Android XML files

When I edit XML files in Eclipse using Android Common XML Editor I am only able to use the graphical layout editor. I see in pictures online how there are supposed to be tabs at the bottom for Graphical and Source but I have none. How do I get this fixed? Using Eclipse 4.2.1. Thanks!
That is probably a problem of Unity not displaying the editor correctly. I bet that you can still switch between the tabs using the keyboard. Press ShiftAltF7 to navigate to the previous page and AltF7 to navigate to the next page of a multi page editor.
I faced same problem so far.
Solution:
==> In your Layout editor there is a android version configuration dropdown box, from there select proper android version. (Eg. "Android 2.3.3")
try this and let me know.
I have discovered that this problem occurs after installing custom theme for eclipse. In my case it was "Dark Juno" theme. Bring back original theme and everythink will be all right again :-)
------ EDIT ------
You can use MoonRise dark theme ( https://github.com/guari/eclipse-ui-theme ). Bottom bar works perfectlly and design looks good.
Please try to use OpenWith ->Layout Editor on the xml file witch u want to open from project explorer under res folder

Would you believe: I can't 'copy' the definition/value of a string item in the eclipse String Editor

I'm using Eclipse 3.7 (Indigo). I have some very long string item definitions/values - e.g. over 1000 characters with a lot of embedded XML segments. The copy function works in the strings.xml tab where the XML characters are replaced by their multi-character equivalents but not the Resources tab. Whenever I select the definition/value text - either by using the cursor or using the shift-arrow keys, I do not activate the 'copy' or 'cut' commands.
Does anyone have the secret?
At the beginning i use to do everything on the resource tab , BUT then i started to have some problems that when i pasted the info it was not showing there, but it was being pasted on the resource node for some reason, so it make it my XML invalid.So i better started to do it on the XML tab, cause is faster also. So when you need to do something fast and pretty, you better do it on the XML tab, is less buggy.
UPDATE:
If your problem is just that you want the text with the values like '&#39' decoded. then you can just copy the text from the XML tab and go to this site and entered there and click decode and you will get your decoded version of your text.
What version of Eclipse do you have? I know some versions have been buggy for keyboard mapping and shortcuts.
Try looking at how those shortcuts are defined. See column "When" in Preferences > General > Keys (image).
Check if those shortcuts do not work for any editor (do they work for Java editor?). If they work for some editors, and not for another, then the problem might be that a plugin setting is causing them to perform another command. You could try disabling all unnecessary plugins.
EDIT:
I also found a bug report on the Eclipse website that affected Eclipse 3.5. It looks like the fix was to go to Window > Preferences > Java > Editor > Typing, then uncheck "Update imports".

Android: Eclipse autocomplete does not work in xml files

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.

Categories

Resources