Is there any Eclipse plugin that takes strings from code and puts them in strings.xml? I found "Externalize strings" function in Eclipse, but I don't know how to get it to work with strings.xml.
Asked
Active
Viewed 6,990 times
15
-
2That'd be amazingly useful wouldn't it? I can't seem to break the habit of writing strings in Java and then manually moving them to resources much later on... a tool to automate this would be very handy indeed. – Reuben Scratton Dec 24 '10 at 17:20
3 Answers
31
Use Refactor in Eclipse:
- highlight the string
- From the Eclipse menu select Refactor -> Android -> Extract Android String.
The string will be moved to strings.xml and the call to getContext().getString(R.string.my_string)
generated.

Patrick
- 11,552
- 7
- 29
- 41

Diego Torres Milano
- 65,697
- 9
- 111
- 134
-
3Can't find Android in Refactor menu. I use Eclipse Galileo version: 1.2.2.20100216-1730 with ADT plugin Version: 8.0.1.v201012062107-82219 – Denis Palnitsky Dec 24 '10 at 17:51
-
-
5I tried to find it in context menu, now i found it in Eclipse menu. Thanks. – Denis Palnitsky Jan 04 '11 at 12:12
-
7
-
-
7
-
`String will be moved to strings.xml and the call getContext().getString(R.string.my_string) generated.` - it doesn't work that way, unfortunately (at least not for me). The conversion leaves the literal string as `R.string.my_string`, causing a type mismatch. – Konrad Morawski Nov 28 '12 at 22:09
-
-
1@Ewoks `CTRL + 1` is my favourite feature of Eclipse and any IDE ever! – Matthew Blackford Mar 28 '13 at 04:45
-
-
@KonradMorawski: are you calling the refactoring from a class that extends Context ? – Mr_and_Mrs_D Sep 28 '13 at 11:40
-
Shift+Alt+A, S - that's broken in newer versions of eclipse - you have to press Shift+Alt+A, then select the refactoring with the mouse - DUH – Mr_and_Mrs_D Sep 28 '13 at 12:22
5
You can also position your cursor over the string literal and press ctrl+1. Then choose "externalize" by the android icon.

Community
- 1
- 1

Cléssio Mendes
- 996
- 1
- 9
- 25
0
use shortcut Alt+Shift+A and after that press S. it'll solve your problem.

MANISH PATHAK
- 2,602
- 4
- 27
- 31