Connect (Forum)
Database Structure
- Language:
- This table stores the list of languages in our system. For each new language, we should insert one record in this table.
- LanguageCulture is ISO language code. You can find a list here of all the ISO language codes. http://www.andiamo.co.uk/resources/iso-language-codes
- Default language in the system is en-GB
- LocalStringResource:
- This table contains the list of translated text.
- LocalResourceKey:
- This table contains the list of Keys that we are using in our code to get the related text.
Using
Throughout the site, you will see the following ways to get your language strings out into the site
Views
Html.Lang("Some.Key")
Html.LanguageString("Some.Key")
Both are the same. The first one is introduced as shorter.
Controllers
LocalizationService.GetResourceString("Some.Key")
Technical
All the needed functions related to language are implemented by LocalizationService class.
Here is the list of some Properties and functions:
CurrentLanguage | Get the Current selected language which is stored in the cookie. |
DefaultLanguage | Get the Default language. |
GetLanguageByLanguageCulture | Get the language object by ISO Culture Code |
GetLanguageByName | Get the language object by the name. |
AllLanguages | Get all the available Languages in our system. |
Switch Language
The _LanguagePartial.cshtml in the Views/Shared contains the functionality of switching between languages.
No Comments