Comments (8)
Our use case is loading Catalog objects via a stream and this covers our scenario.
For full context we make games. We parse a folder full of .mo files to know what languages we have translations for, and then display the known options in a language menu so that the user can easily switch language.
Right now we are manually extracting the language header and reading it. It works fine, but it feels like it should have been part of the GetText library.
Thanks for your great work.
from gettext.net.
this is now fixed/updated in code.
A new package version (> 0.9.8) will be out in the next couple days
from gettext.net.
this is all based on the original NGetText code and I never looked into it, but can clearly see that using CultureInfo.CurrentUICulture certainly is not really a good idea.
I'll need to dig bit deeper to see if there are any side effects when changing this, but clearly should be changed.
from gettext.net.
looking further, I could see two issues here:
- typically the culture is set in the application, and the appropriate catalog loaded i.e.
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(fr-FR);
ICatalog catalog = new Catalog("myCatalog");
or alternatively
ICatalog catalog = new Catalog("myCatalog", new CultureInfo(fr-FR));
in that case, the catalog would try to load the catalog matching the given or current culture, so the CultureInfo of the catalog should match that. However, if a catalog for the exact culture ("fr-FR") is not found, it will lookup the hierarchy, and i.e. find a catalog matching "fr" only. In that case, the CultureInfo property of the catalog would still be "fr-FR" instead of "fr", which needs to be updated.
- the other case is if you're pointing directly to a file (stream) or ILoader interface. In that case, your application CultureInfo.CurrentUICulture may be i.e. en-US, but you may open a catalog from stream
ICatalog catalog = new Catalog(new Catalog(new FileStream("catalog_fr-FR.mo"));
so the catalog's CultureInfo will be en-US instead of fr-FR which is wrong obviously.
I'll update both cases. Could you just confirm this is covering your scenario, or is there something else I haven't seen yet?
from gettext.net.
reasonable to expect the CultureInfo property set out of the loaded catalog, I'll work on that.
just for curiousity, how are the *.mo files named?
In most cases I've seen and used, either the mo-files where using the language code as filename (fr-FR.mo), or in a respective folder structure (fr-FR\catalog.mo)
from gettext.net.
just for curiousity, how are the *.mo files named?
In our case we also use the locale as the filename. Normally just the neutral locale (e.g. fr.mo
) unless we have some region specific translations.
This does mean we could have fallen back to the filename to also know the catalog's locale, or to know available locales without actually parsing them, but when you have a bunch of files being generated by external tooling its quite easy to copy the wrong file or name it incorrectly. It's safer to validate against the language header.
from gettext.net.
https://www.nuget.org/packages/GetText.NET/0.9.9
from gettext.net.
Perfect. Thanks for the quick update.
from gettext.net.
Related Issues (20)
- Another control properties HOT 5
- ObjectListView columns' header title doesn't localize HOT 4
- Non-localizable controls
- Escaped strings are not correctly handled HOT 7
- ContextMenuStrip is not localized HOT 3
- Extractor fails when enum description not applied on all members
- GetText.Extractor: bug with ternary operator ?: HOT 6
- Non-localizable control-content
- Unhandled exception: System.ArgumentException: The SetHandler call for command 'GetText.Extractor' is missing an Argument or Option for the parameter at position 4 HOT 2
- PathExtension requires Windows dll import HOT 6
- Bug (?) with aliases requiring member syntax HOT 2
- GetText.Extractor output is nondetererministic HOT 2
- Extractor wrongly extracts interpolated strings with strings inside of them HOT 3
- Refactor commandline options for CommandLine package upgrade limiting options to 8
- Upgrade (Extractor) to .NET 6 HOT 2
- Strong name signing assemblies HOT 2
- Wrong text extraction HOT 6
- Ignore wrongly extracted string HOT 3
- This can work with GtkSharp and glade file?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gettext.net.