需要编写用于基于给定主文件创建键值对本地化文件的脚本

I have localization resource files in 9 languages in key value format(.java files). I need to create 9 other localization files based on the keys present in English file(en.yml). The later one is like a subset of the previous one and may contain some extra keys.Based on the keys given in en.yml file I need to select strings from java files (for all 9 files) and create corresponding localization (yml) files for each language.

I need to write a script which I can run any time to create yml files based on English yml file picking the strings from base java files as mentioned above.

Can any body help me in writing the script. Which language will be better?

Load the the English Properties file:

Properties properties = new Properties();
try {
   properties.load(new FileInputStream("path/filename"));
 } catch (IOException e) {
   ...
 }

For every language you need to support: create .properties file named %filename%_%LANG%.properties. Load relevan language specific properties. Iterate over your English keys enumeration and put the corresponding(language-specific) values in the localized file:

// create localized .properties file and load values for look-up
for(String key : properties.stringPropertyNames()) {
   String value = properties.getProperty(key);
   // put the value in the localized file;
}

If I understand your question correctly; You have 9 .java files (.properties format?) with translated values, and one .yml file with the English strings. You are looking for a script that matches the values from the .java files and writes them to new .yml files, based on the keys in the English .yml file.

You say you need a script which you can run any time. I assume this is because of possible future updates, and managing all the translations etc?

If you have to work with several translations, I think it's better to keep a separate translation spreadsheet or database, and use this to generate the files you need. This is easier because you can add or update values in one central place, and you can write a script or macro to generate the translation files you need (.strings or .xml or whatever).