Giter Club home page Giter Club logo

Comments (7)

AndrewKeepCoding avatar AndrewKeepCoding commented on September 27, 2024 1

Sorry for the delay.
This is a sample app is created with the TemplateStudio. Let me know if you have any questions.

TemplateStudioWinUI3LocalizerSampleApp

from winui3localizer.

AndrewKeepCoding avatar AndrewKeepCoding commented on September 27, 2024

Hi! Is your app a packaged app (default) ? or a non-packaged app?

from winui3localizer.

p6laris avatar p6laris commented on September 27, 2024

It's is packaged app sir, Generated with Template Studio.

from winui3localizer.

AndrewKeepCoding avatar AndrewKeepCoding commented on September 27, 2024

I'm working on a sample app generated with the TemplateStudio. Just give me a few days🔥

from winui3localizer.

p6laris avatar p6laris commented on September 27, 2024

Thanks, appreciated so much 🙏

from winui3localizer.

p6laris avatar p6laris commented on September 27, 2024

Sir,
When i try to initialize the localizer, strangely this exception will throw. any idea why?
WinUI3Localizer.LocalizerException: 'Failed to set language. [{PreviousLanguage} -> {NextLanguage}]'

from winui3localizer.

AndrewKeepCoding avatar AndrewKeepCoding commented on September 27, 2024

Sorry. That exception message is going to be fixed in the next version.
You might get this message when the SetLanguage(string language) method is called but failed to find the language.

This is how the SetLanguage method is implemented inside the WinUI3Localizer.

    public async Task SetLanguage(string language)
    {
        string previousLanguage = CurrentDictionary.Language;

        try
        {
            if (this.languageDictionaries.TryGetValue(
                language,
                out LanguageDictionary? dictionary) is true &&
                dictionary is not null)
            {
                CurrentDictionary = dictionary;
                await LocalizeDependencyObjects();
                OnLanguageChanged(previousLanguage, CurrentDictionary.Language);
                return;
            }
        }
        catch (LocalizerException)
        {
            throw;
        }
        catch (Exception exception)
        {
            ThrowLocalizerException(exception, "Exception setting language. [{PreviousLanguage} -> {NextLanguage}]", previousLanguage, language);
        }

        ThrowLocalizerException(innerException: null, "Failed to set language. [{PreviousLanguage} -> {NextLanguage}]", previousLanguage, language);
        return;
    }

My first guess is that you are not setting the DefaultLanguage in the options:

ILocalizer localizer = await new LocalizerBuilder()
    .SetOptions(options =>
    {
        options.DefaultLanguage = "YOUR DEFAULT LANGUAGE";
    }
    .Build();

You also need to make sure that your default language is added as a LanguageDictionary.

from winui3localizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.