AlexTeixeira/Askmethat-Aspnet-JsonLocalizer

I18N - Exception while getting relevant culture file when folders have "." in folder name Ex: "Culture is not supported. (Parameter 'name')\r\n <folderpartname> is an invalid culture identifier."

rohanreddyg opened this issue · 4 comments

Hi,

Getting exception while retrieving a localized string using GetString method of IStringLocalizer class. Below is the exception:
Culture is not supported. (Parameter 'name')\r\n <FolderPartName" is an invalid culture identifier.

Root Cause:
This exception occurs when a I18N JSON resource files with format like "localization.en-US.json" is in a folder path which has atleast one folder in the heirarchy with a dot (".") in its name.
This is because filename splitter is assuming that only filenames will have dot in the absolute path. which may not be the case.

Fix:
Fix is to use Path.GetFileName to first get filename from the absolute folder path and then try to retrieve the file culture details from last but one index of filename split array.

raised pull request 84 for fixing this issue. Please accept and release a Nuget Package asap.
#84

Thanks,

same issue with the last version of nuget package

@AlexTeixeira can you release the fix on nuget?

sc3w commented

Same issue here. Is this going to be fixed?

Hi,

Sorry I was very busy this last few months.

I will update the nuget today.