I18n (english): Porovnání verzí
Z Freenetis Wiki
(Založena nová stránka: cs:I18n) |
|||
(Není zobrazena jedna mezilehlá verze od jednoho dalšího uživatele.) | |||
Řádek 1: | Řádek 1: | ||
[[cs:I18n]] | [[cs:I18n]] | ||
+ | [[ru:I18n (русский)]] | ||
+ | |||
+ | Internationalization in FreenetISu covers two areas: | ||
+ | * Strings that are contained in the source code - this is done using the language files in i18n | ||
+ | * Strings in the database - string in the database is usually not necessary to translate. The exceptions are enumerated types - eg types of members, facilities, contacts that you can edit through a web interface. Since the installation Freenetis contains basic values for these types, it is necessary for them to think about internationalization. | ||
+ | |||
+ | Enumerated types are implemented using two tables: | ||
+ | |||
+ | {| Border = "1" class = "wikitable" | ||
+ | | + Enum_types: | ||
+ | ! id! type_id! value | ||
+ | | - | ||
+ | | 1 | | 1 (eg type = member) | | Applicant | ||
+ | | - | ||
+ | | 2 | | 1 | | Regular member | ||
+ | | - | ||
+ | | 3 | | 1 | | Honorary member | ||
+ | | - | ||
+ | | 4 | | 2 (eg = contact type) | | Phone | ||
+ | | - | ||
+ | | 5 | | 2 | | ICQ | ||
+ | | - | ||
+ | | 6 | | 2 | | Skype | ||
+ | |} | ||
+ | Table enum_types contains a listing of all types in the default language (here English is selected) | ||
+ | |||
+ | Translations for each row of enum_types we obtain from the table translations: | ||
+ | |||
+ | {| Border = "1" class = "wikitable" | ||
+ | | + Translations: | ||
+ | ! id! original_term! translated_term! lang | ||
+ | | - | ||
+ | | 1 | | Regular member | | Řádný člen | | cs | ||
+ | | - | ||
+ | | 2 | | Regular member | | Regular member | | en | ||
+ | | - | ||
+ | | 3 | | Regular member | | ordentlich Mitglied | | de | ||
+ | | - | ||
+ | | 4 | | Phone | | Phone | | cs | ||
+ | | - | ||
+ | | 5 | | Phone | | Phone | | de | ||
+ | | - | ||
+ | |} | ||
+ | |||
+ | Due to the fact that both tables are interrelated by key, you can use the table translations and translation of terms from other tables than enum_types. | ||
+ | |||
+ | Common query to get id and the corresponding strings for a particular language types of members (type_id = 1): | ||
+ | |||
+ | SELECT enum_types.id, IFNULL(translations.translated_term,enum_types.value) as value FROM enum_types | ||
+ | LEFT JOIN translations on enum_types.value = translations.original_term | ||
+ | WHERE enum_types.type_id=1 AND translations.lang="cs" |
Aktuální verze z 10. 12. 2013, 12:14
Internationalization in FreenetISu covers two areas:
- Strings that are contained in the source code - this is done using the language files in i18n
- Strings in the database - string in the database is usually not necessary to translate. The exceptions are enumerated types - eg types of members, facilities, contacts that you can edit through a web interface. Since the installation Freenetis contains basic values for these types, it is necessary for them to think about internationalization.
Enumerated types are implemented using two tables:
+ Enum_types: | id! type_id! value | - | | 1 (eg type = member) | | Applicant | - | | 1 | | Regular member | - | | 1 | | Honorary member | - | | 2 (eg = contact type) | | Phone | - | | 2 | | ICQ | - | | 2 | | Skype |
---|
Table enum_types contains a listing of all types in the default language (here English is selected)
Translations for each row of enum_types we obtain from the table translations:
+ Translations: | id! original_term! translated_term! lang | - | | Regular member | | Řádný člen | | cs | - | | Regular member | | Regular member | | en | - | | Regular member | | ordentlich Mitglied | | de | - | | Phone | | Phone | | cs | - | | Phone | | Phone | | de | - |
---|
Due to the fact that both tables are interrelated by key, you can use the table translations and translation of terms from other tables than enum_types.
Common query to get id and the corresponding strings for a particular language types of members (type_id = 1):
SELECT enum_types.id, IFNULL(translations.translated_term,enum_types.value) as value FROM enum_types LEFT JOIN translations on enum_types.value = translations.original_term WHERE enum_types.type_id=1 AND translations.lang="cs"