是否有任何工具到iPhone本地化的字符串文件转换为可在Android中使用的字符串资源文件? [英] Are there any tools to convert an Iphone localized string file to a string resources file that can be used in Android?

查看:156
本文介绍了是否有任何工具到iPhone本地化的字符串文件转换为可在Android中使用的字符串资源文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有本地化的字符串文件所使用的iPhone应用程序,我的工作移植到Android系统。是否有通过从X code项目所采取的文件,并建立使用Android中的字符串所需要的XML的任何工具?

I have the localized strings file that is used in the Iphone app that I work on to port to Android. Are there any tools that go through the file taken from the xcode project and build the xml needed to use the strings in android?

由于苹果文件是一个简单的键值文件是有,在这种格式转换成字符串的工具

As the apple file is a simple key value file is there a tool that converts string in this format

键=值

这样:

<字符串名称=键>值小于/串>

这个工具应该是很容易建立,但我AP preciate任何指针已经工作的工具。

This tool should be easy to build but I appreciate any pointers to already working tools.

推荐答案

好吧,我写我自己的小转炉利用从亚历克斯code一点点。

Ok i wrote my own little converter using a little bit from the code from alex.

public static void main(String[] args) throws IOException {
    Scanner fileScanner =
            new Scanner(new FileInputStream(args[0]), "utf-16");
    Writer writer =
            new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
                    new File(args[1])), "UTF8"));
    writer.append("<?xml version=\"1.0\" encoding=\"utf-8\"?> <resources>");
    while (fileScanner.hasNextLine()) {
        String line = fileScanner.nextLine();
        if (line.contains("=")) {
            line = line.trim();
            line = line.replace("\"", "");
            line = line.replace(";", "");
            String[] parts = line.split("=");
            String nextLine =
                    "<string name=\"" + parts[0].trim() + "\">"
                            + parts[1].trim() + "</string>";
            System.out.println(nextLine);
            writer.append(nextLine);
        }
    }
    fileScanner.close();
    writer.append("</resources>");
    writer.close();
}

这是一个有点棘手获取Java正确的读写UTF 16个输入我离开的X code项目,但现在,它正在像一个魅力。

It was a little bit tricky to get Java to correctly read and write the UTF 16 input I got out of the xcode project but now it is working like a charm.

这篇关于是否有任何工具到iPhone本地化的字符串文件转换为可在Android中使用的字符串资源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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