In order to build versions that have various language translations, I can call the builder-cli.exe with a parameter project.allowedLanguages.

How can I only place the needed translation files (for our application) which are listed in that parameter?

The file names are of the form messages_xx.properties where the xx matches the codes in allowedLanguages, i.e. English is messages_en.properties, German is messages_de.properties.

It seems like it should be possible to only include these message.properties files that match the codes in the allowedLanguages list, but I'm not seeing a way to do it.

Thank you very much for any help you can offer.

-Will

asked 24 Jan, 15:01

surferwill's gravatar image

surferwill
6114
accept rate: 0%


Unfortunately it's not possible to conditionally add languages to the <customLanguageFileList>.

it's possible though to pack only the custom language files from the languages in the <allowedLanguages>by using the <foreach> action to iterate over the allowedLanguages property and copy the resulting files to a temporary folder, which can then be packed.

First in the <prebuildactionlist> you create a directory where the files will be copied.

<preBuildActionList>
   ...
    <createDirectory>
      <path>/tmp/tempfiles</path>
    </createDirectory>

... Then in the same <prebuildactionlist> you add a <foreach> action to iterate over the allowedLanguages property.

  <foreach values="${project.allowedLanguages}">
      <variables>lng</variables>
      <actionList>
        <copyFile>
          <origin>/path/to/your/messages_${lng}.properties</origin>
          <destination>/tmp/tempfiles</destination>
        </copyFile>
      </actionList>
    </foreach>
 ...

</prebuildactionlist> And ultimately you pack the files from your temporary folder /tmp/tempfiles:

<folder>
<destination>${installdir}</destination>
 ...

  <distributionFileList>
        <distributionFile>
          <origin>/tmp/tempfiles/*</origin>
          <allowWildcards>1</allowWildcards>
        </distributionFile>
    </distributionFileList>
     ...
     </folder>

The problem is that if the builder encounters a language in <allowedLanguages> that has no custom .lng file it will throw an error. A workaround for this would be to create an empty custom .lng file for every language your installer supports. InstallBuilder will ignore the empty .lng files and only apply the ones that have your custom strings.

link

answered 31 Jan, 12:12

Michiel's gravatar image

Michiel ♦
33614
accept rate: 18%

edited 31 Jan, 12:13

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×5

Asked: 24 Jan, 15:01

Seen: 76 times

Last updated: 31 Jan, 12:13