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

Enhancement: Translation using Resources file #1

Open
a2937 opened this issue Oct 18, 2018 · 3 comments
Open

Enhancement: Translation using Resources file #1

a2937 opened this issue Oct 18, 2018 · 3 comments

Comments

@a2937
Copy link

a2937 commented Oct 18, 2018

I found a solution that you might be interested in. I would actually be more than happy to help implement and create a pull request to resolve. By using a resx file to hold string values, it can be translated. I would try to see if I can add the current culture information to your object and file. That way it will be able to be set while it is running via command, theoretically.

More about resx files.
https://docs.microsoft.com/en-us/dotnet/framework/resources/working-with-resx-files-programmatically

@JanVargovsky
Copy link
Owner

JanVargovsky commented Oct 20, 2018

It would be great. There are methods Before/After execute of a command so you can set the correct culture information based on config here. However I see that I'm using multiple base classes from Discord.Net/Discord.Net.Interactive libraries such as ModuleBase, ModuleBase<T> and InteractiveBase<T>, so every class would have to override it on its own - not in every module but rather create some own base classes for it and just derive from them.

Do you need some help or guidance?

@a2937
Copy link
Author

a2937 commented Oct 20, 2018

I have been looking at the summary attribute and wondering how to localize those. They don't seem to like allowing non-certain text values. Also I am partial just to just letting the hosted location determine the localization, as I am not quite sure how to read from your config file. Also I am trying to find an efficient way of getting into the resx file and having to specify the locale every single time. I am considering an extension method somewhere perhaps. In addition concepts are a little more difficult when you apply them.

@JanVargovsky
Copy link
Owner

Summary attribute can still remain as a key to a resources. Its not about the host, currently the bot is being used across a few guilds (servers - Discord terminology). Each guild can specify its own language. It has to be configurable so every guild can choose what language they would like to use.

I found this package named Microsoft.Extensions.Localization that has this factory. IStringLocalizer looks better to me rather than your proposed ResourceManager that is there for a couple for years (its quite obsolete in my view and there are better approaches nowadays). I would like to have only one resx file per language (Global.en.resx, Global.cs.resx etc.) in Resources folder. Just wrap the mentioned factory class into e.g. LocalizationService, load resource based on thread's culture and that is basically it.

Configuration is only about adding a new property e.g. Language to GuildOptions, then it will be automatically loaded from configuration*.json files.

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

No branches or pull requests

2 participants