adamduncan / eleventy-plugin-i18n

Eleventy plugin to assist with internationalization and dictionary translations
MIT License
103 stars 10 forks source link

Could not find translations. #2

Closed x8BitRain closed 4 years ago

x8BitRain commented 4 years ago

Hey, thanks for making this, looks really good!

I tried setting up this plugin with the following boilerplate code: https://github.com/mattwaler/eleventy-starter

But despite following your setup guide exactly, I can't get the translations to load any way.

The console always outputs. [i18n] Could not find 'hello' in 'fr-FR'. Using 'en-GB' fallback.

My code is here: https://github.com/x8BitRain/starposter-landingpage-11ty

Live: https://unruffled-mcnulty-3af42b.netlify.app/fr-fr/

The big "Hello" at the top of the page is where the Bonjour is supposed to be.

Is there something with this boilerplate's configuration that's causing this not to work?

Thanks.

adamduncan commented 4 years ago

Hey @x8BitRain, thanks for checking out the plugin.

You are correct. This is a bug. I'll dig in and let you know what I find.

adamduncan commented 4 years ago

Interestingly, this might be a versioning thing.

It seems as though the options argument being passed to addPlugin(i18n, options) is coming through empty, hence no translations. Even though that argument was added way back in 11ty 0.5.4.

The @11ty/eleventy version you're using is currently at 0.9.0. This plugin sets its peerDependencies for 11ty at 0.11.0. Perhaps something is going awry there.

Side note: You helped me spot that I'd also not properly published the latest 0.1.0. Have now republished 0.1.1 — The "Hello" you were seeing was a hangover from 0.1.0's test data.

So, to resolve:

Hope that sets you on the right path.

x8BitRain commented 4 years ago

Awesome, thanks! I was just about to tell you that I found that it never receives the configGlobalOptions parameter so it defaults to the example config all the time.

I did get it working in the end with by adding config.addFilter('i18n'..... manually but I'll try update now, cheers.