- Moderator
- #1
Problem: Skin authors are often forced to hard code strings in their skins for the plugins that do not support localization or for the various strings they see fit in the skin but the string isn't available in standard MediaPortal localization strings. Being a skinner myself, i hated that, something had to be done.
Solution: SkinTranslations![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
This is a *very* simple plugin and I'm surprised no one has done it before (excuse me if I'm wrong). Basically it'll look for "Translations" folder in your skin folder, match localization from MediaPortal configuration and look for proper translation XML file. If that one doesn't exist, English is used as default (as always). You can then access the translated strings using GUI properties like this: #SkinTranslation.Translations.*FIELD*.Label where *FIELD* is to be replaced with the value from translation XML. Example translation XML looks like this:
In that example, #SkinTranslation.Translations.ExampleTranslation.Label would give you "Example of translated string" in the skin and #SkinTranslation.Translations.ExampleTranslationFromMediaPortal.Label would give you "Episode" in the skin (the string is taken from MediaPortal language files.
If user changes skin or language using GUI settings, translations are updated accordingly.
As a skin author, this is what you have to do:
1. Create folder Translations in your skin root
2. Add translation files. Default translation file is "en-US.xml"
3. Add more translation files for different languages or ask users for translations![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
That's it. Check the attachment![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Change log:
v0.7
english translations are now loaded first, user language translation after that; this ensures that even if language is out of date, english translations will still be loaded
language for mediaportal 1.2 is now read from correct place in MediaPortal.xml
v0.6
small logging fixes
added possibility for translations from MediaPortal language files
v0.5
initial release
Note: this plugin is not designed for the end users. It's created for skin authors to distribute it with their skins. End users will just enjoy the results![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Solution: SkinTranslations
This is a *very* simple plugin and I'm surprised no one has done it before (excuse me if I'm wrong). Basically it'll look for "Translations" folder in your skin folder, match localization from MediaPortal configuration and look for proper translation XML file. If that one doesn't exist, English is used as default (as always). You can then access the translated strings using GUI properties like this: #SkinTranslation.Translations.*FIELD*.Label where *FIELD* is to be replaced with the value from translation XML. Example translation XML looks like this:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- Skin translation file -->
<!-- English (US) -->
<strings>
<!--<string Field="ExampleTranslation">Example of translated string</string>-->
<!--<string Field="ExampleTranslationFromMediaPortal">874</string>-->
<!-- # -->
<!-- A -->
<!-- B -->
<!-- C -->
<!-- D -->
<!-- E -->
<!-- F -->
<!-- G -->
<!-- H -->
<!-- I -->
<!-- J -->
<!-- K -->
<!-- L -->
<!-- M -->
<!-- N -->
<!-- O -->
<!-- P -->
<!-- Q -->
<!-- R -->
<!-- S -->
<!-- T -->
<!-- U -->
<!-- V -->
<!-- W -->
<!-- X -->
<!-- Y -->
<!-- Z -->
</strings>
In that example, #SkinTranslation.Translations.ExampleTranslation.Label would give you "Example of translated string" in the skin and #SkinTranslation.Translations.ExampleTranslationFromMediaPortal.Label would give you "Episode" in the skin (the string is taken from MediaPortal language files.
If user changes skin or language using GUI settings, translations are updated accordingly.
As a skin author, this is what you have to do:
1. Create folder Translations in your skin root
2. Add translation files. Default translation file is "en-US.xml"
3. Add more translation files for different languages or ask users for translations
That's it. Check the attachment
Change log:
v0.7
english translations are now loaded first, user language translation after that; this ensures that even if language is out of date, english translations will still be loaded
language for mediaportal 1.2 is now read from correct place in MediaPortal.xml
v0.6
small logging fixes
added possibility for translations from MediaPortal language files
v0.5
initial release
Note: this plugin is not designed for the end users. It's created for skin authors to distribute it with their skins. End users will just enjoy the results