claudetech / node-static-i18n

HTML static pages i18n tool
https://www.npmjs.com/package/static-i18n
MIT License
104 stars 21 forks source link

How to change the layout of the outputOther? #43

Open velidan opened 3 years ago

velidan commented 3 years ago

Hi everyone and thanks for the awesome lib. I have an issue: I have the English and German languages and I need to receive at the output index_en.htmland index_de.html

The question: How to do it?

I managed how to change the default language name (en) by just hardcoding it in the config but I can't do the same for other languages because they should be dynamic.

Thanks for any help!

my config

    StaticI18n.processDir(paths.tempHandlebars, {
      locale : 'en',
      outputDefault: 'index_en.html', // just hardcoded
      outputOther: '__lng__/index___lng__.html', // doesn't work
      localesPath : paths.locales,
      outputDir  : paths.tempI18n,
      locales: localeNames
    })
danhper commented 3 years ago

Hi, I just pushed a new version which should allow you to do this. You can now use __basename__ in the filename, which will strip the extension. In your case, the following should now work:

static-i18n -l en -i en -i ja --output-default '__basename_____lng__.html' --output-other '__basename_____lng__.html' /path/to/data

You should of course also be able to do it programmatically, as you were doing. Please let me know if that works for you.