AlexTeixeira / Askmethat-Aspnet-JsonLocalizer

Json Localizer library for .NetStandard and .NetCore Asp.net projects
MIT License
91 stars 29 forks source link

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." #85

Closed rohanreddyg closed 3 years ago

rohanreddyg commented 4 years ago

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.

rohanreddyg commented 4 years ago

raised pull request 84 for fixing this issue. Please accept and release a Nuget Package asap. https://github.com/AlexTeixeira/Askmethat-Aspnet-JsonLocalizer/pull/84

Thanks,

adiso55000134 commented 4 years ago

same issue with the last version of nuget package

@AlexTeixeira can you release the fix on nuget?

sc3w commented 4 years ago

Same issue here. Is this going to be fixed?

AlexTeixeira commented 4 years ago

Hi,

Sorry I was very busy this last few months.

I will update the nuget today.