only include language files listed in project.allowedLanguages

Answered

Comments

1 comment

  • Avatar
    michiel

    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.

Please sign in to leave a comment.