Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Invalid Culture when using I18N mode JSON Files #129

Open
ahofman opened this issue May 24, 2022 · 0 comments
Open

Invalid Culture when using I18N mode JSON Files #129

ahofman opened this issue May 24, 2022 · 0 comments

Comments

@ahofman
Copy link

ahofman commented May 24, 2022

Hi there,
I'm using a set of JSON files with localised strings, for example:

localization.json
localization.nl.json 

Where localization.json is the fallback locale (en-US) and localization.nl.json is Dutch.

When the request locale is nl a CultureNotFoundException is thrown with the message

Culture is not supported. (Parameter 'name')
localization is an invalid culture identifier.

from here:

var fileCulture = new CultureInfo(fileName.Split('.')[^2] ?? String.Empty);

The issue is that the default localization.json file is being treated as a locale file, and the string.split()[^2] resolves to localization, which it then tries to create a CultureInfo from, which is invalid.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant