DarkLiKally / I18Next.Net

A port of the i18next javascript library for .Net platforms based on .Net Standard 2.0
Apache License 2.0
54 stars 30 forks source link

Split up language files #11

Closed mwillems1994 closed 3 years ago

mwillems1994 commented 4 years ago

I was wondering how and if i can split up language files. For an example i would like to have the following folder structure: locales/Controllers/Home/en.json locales/Models/Home/en.json locales/Services/Home/en.json

Is that possible? The default localisation .net Core offers, tries to guess where the localisations files are based on the path of the actual cs file. Unfortunately i am unable to figure out how it works with this library.

DarkLiKally commented 4 years ago

Not with the default providers, the default json file backend expects a structure like locales/{language-code}/{namespace}.json

but you can easily implement your own backend - inspired by the default josn backend - which handles your custom structure. also if you want to do custom namespace resolving from the string localizer generic context - you should be able to easily implement a custom one for your scenario which uses the typeof(T) information to automatically retrieve the translation namespace from the .net namespace.