Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to generate multi-language resource files #20

Open
Korne127 opened this issue May 8, 2024 · 0 comments
Open

Add support to generate multi-language resource files #20

Korne127 opened this issue May 8, 2024 · 0 comments

Comments

@Korne127
Copy link

Korne127 commented May 8, 2024

The VarFileInfo block in a ResourceFile looks roughly like this:

BLOCK "VarFileInfo"
{
    VALUE "Translation", 0x409, 0x04b0
}

However, according to the Microsoft documentation

[The block] typically contains a list of languages that the application or DLL supports.

The structure should list the supported languages. This is a list with variable length. For example, it could look like VALUE "Translation", 0x409, 0x04b0, 0x0407, 0x04b0 for English (US) and German.

The Microsoft documentation further states that

If you use the Var structure to list the languages that your application supports, the number of StringTable structures in the version resource is directly related to the number of language/code page identifier pairs in the Value member of the Var structure.

I'm not an expert with ResourceFiles but I think that you're supposed to add a StringTable (containing ProductName, ProductVersion, FileVersion, InternalName, etc.) for each language you support.

To create a multi-language resource file, the crate might need to become more modular, allowing one to set the StringTable strings for any language.
I think the best way to do this would be to have a function like add_translation(&mut self, language: u16) -> &mut StringTable that creates a StringTable struct for that language and returns it. You could set any String in a StringTable with a set function (like you do now), but unless you overwrite a value specifically for a specific language, the values given from Cargo or the global (current) set method would be used (like they are now).
This way, you wouldn't need to set the mostly same values over and over again but can use the crate like now and just call add_translation for each language that should be included, and you still have the possibility to overwrite specific values for each language. And all the added languages are included in the VarFileInfo block.
This would replace set_language.

What do you think about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant