安卓:有没有一种简单的方法来找到我的项目中的所有字符串? [英] Android: is there an easy way to find all the Strings in my project?

查看:218
本文介绍了安卓:有没有一种简单的方法来找到我的项目中的所有字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要扫描我的Andr​​oid项目的所有硬盘codeD字符串这样我就可以本地化的项目,把字符串中的strings.xml。我看到在Eclipse中外部化字符串...的选项,但它不是具体到Android。

I want to scan my Android project for all hardcoded Strings so I can localize the project, putting the Strings in strings.xml. I see an option in Eclipse to 'Externalize Strings...' but it isn't specific to Android.

我知道可以重构各个串但我想重构所有该字符串一次。我有一吨的文件,而我试图避免经过人工每个人。

I know you can refactor individual strings but I'd like to refactor all the Strings at once. I've got a ton of files, and I'm trying to avoid going through each one manually.

推荐答案

我只想打开一个终端窗口(腻子,如果你是在Windows上)在项目的根目录下。然后,您可以运行类似如下:

I would just open up a terminal window(putty if you are on windows) at the root directory of your project. You can then run something like the following:

grep -r --include=*.java '="[^"\r\n]*"' ./*  --to look for something like this String test="text";, a string with =""
or
grep -r --include=*.java '"[^"\r\n]*"' ./*  -- to look for any string, anything enclosed in ""

当然,接下来的部分是真正替代串入的strings.xml,这可能是脚本出来为好,但可能需要更多的修修补补。

Of course the next part is to actually substitute the Strings into the Strings.xml, that could be scripted out as well, but may take more tinkering.

这篇关于安卓:有没有一种简单的方法来找到我的项目中的所有字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆