Translate BH Weather

Hi i have been trying to translate the plugin BH Weather to Swedish

And are really stuck. I have added the translation files and my custom _init_py file

Is this possible or are i am on a impossible mission here @nunigaia ;)

translate.jpg
 

Attachments

  • BhWeather.zip
    2.8 KB · Views: 8

AlexWilMac

Moderator
I see you added a space before each of the ":". So you have, for instance, "Humidity :". This is also for every other similar cases.
I can't try this plugin under BH now, but are you sure this space is really present in the English message? You can try just one of them to check this fact.

msgid "Humidity:"
msgstr "Luftfuktighet:"

and see if it works.
 

AlexWilMac

Moderator
But if you used only Poedit, it can't change the original messages, only the translation.
I thought you had used a text editor and you added the msgid yourself.
But if you used only Poedit, my theory should be wrong ;)
 

nunigaia

Moderator
Poedit accully gave warnings when i hade no space but i will try and see usally you are right :)

No.

Appart from msgid ( must be the correct ones, with the same number of caracters and spaces ), i.e, must be the same as the msg strings of the plugin, though, you have to:

* Add all Bhweather ( msgid and msgstr ) to enigma2, as there are no translations to BHWeater Plugin, and all will fit at ( BlackHole enigma2.po ) and enigma2.mo file ( this one the compiled ).

If you do that, you are done :)

By the way, for example, this are the "msgid" for the strings:

Code:
msgid "Humidity: "
msgstr ""

msgid "Feelslike: "
msgstr ""

msgid "Precip: "
msgstr ""

msgid "Wind speed: "
msgstr ""

Note: In this case after the "colon" you have a space before the "quotation marks"
 
So its impossible to add locale to the plugin its self?

I have modify the _init_py file like EPGImport plugin that use its own locale translation

And Alex i have exctracted the source with Poedit from the python file


msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2020-04-26 21:07+0200\n"
"PO-Revision-Date: 2020-04-28 00:20+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.3\n"
"X-Poedit-Basepath: ../..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n"

#: plugin.py:25
msgid "Retrieving data ..."
msgstr "Hämtar Väderdata ..."

#: plugin.py:143
msgid "Data provider :"
msgstr "Väderdata leverantör : "

#: plugin.py:149
#, python-format
msgid "Last Updated : %s:%s"
msgstr "Senast Uppdatering : %s:%s"

#: plugin.py:159
msgid "Humidity :"
msgstr "Luftfuktighet :"

#: plugin.py:162
msgid "FeelsLike :"
msgstr "Känns som :"

#: plugin.py:165
msgid "Precip :"
msgstr "Nederbörd :"

#: plugin.py:168
msgid "Wind display :"
msgstr "Visning Vind :"

#: plugin.py:171
msgid "Wind speed :"
msgstr "Hastighet Vind :"

#: plugin.py:174
msgid "Ob. point :"
msgstr "Ob, punkt :"

#: plugin.py:179 plugin.py:193
msgid "High :"
msgstr "Hög :"

#: plugin.py:182 plugin.py:196
msgid "Low :"
msgstr "Låg :"

#: plugin.py:206
msgid "Latitude :"
msgstr "Latitude :"

#: plugin.py:209
msgid "Longitude :"
msgstr "Longitude :"

#: plugin.py:212
msgid "Timezone :"
msgstr "Tids son :"

#: plugin.py:219 plugin.py:261
msgid "Change city"
msgstr "Byt Stad"

#: plugin.py:257
msgid "About"
msgstr "Om"

#: plugin.py:260
msgid "Enter the city name :"
msgstr "Skriv stad eller plats :"

#: plugin.py:277
msgid "Sorry no matches found"
msgstr "Ingen plats funnet"

#: plugin.py:313
msgid "Press ok to confirm"
msgstr "Tryck på OK för att bekräfta"

#: plugin.py:338
msgid "Weather forecast"
msgstr "Väderprognos"

#: plugin.py:348
msgid "World Weather Forecast"
msgstr "Världs väderprognos"
 

nunigaia

Moderator
So its impossible to add locale to the plugin its self?

I have modify the _init_py file like EPGImport plugin that use its own locale translation

And Alex i have exctracted the source with Poedit from the python file


msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2020-04-26 21:07+0200\n"
"PO-Revision-Date: 2020-04-28 00:20+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.3\n"
"X-Poedit-Basepath: ../..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SearchPath-0: .\n"

#: plugin.py:25
msgid "Retrieving data ..."
msgstr "Hämtar Väderdata ..."

#: plugin.py:143
msgid "Data provider :"
msgstr "Väderdata leverantör : "

#: plugin.py:149
#, python-format
msgid "Last Updated : %s:%s"
msgstr "Senast Uppdatering : %s:%s"

#: plugin.py:159
msgid "Humidity :"
msgstr "Luftfuktighet :"

#: plugin.py:162
msgid "FeelsLike :"
msgstr "Känns som :"

#: plugin.py:165
msgid "Precip :"
msgstr "Nederbörd :"

#: plugin.py:168
msgid "Wind display :"
msgstr "Visning Vind :"

#: plugin.py:171
msgid "Wind speed :"
msgstr "Hastighet Vind :"

#: plugin.py:174
msgid "Ob. point :"
msgstr "Ob, punkt :"

#: plugin.py:179 plugin.py:193
msgid "High :"
msgstr "Hög :"

#: plugin.py:182 plugin.py:196
msgid "Low :"
msgstr "Låg :"

#: plugin.py:206
msgid "Latitude :"
msgstr "Latitude :"

#: plugin.py:209
msgid "Longitude :"
msgstr "Longitude :"

#: plugin.py:212
msgid "Timezone :"
msgstr "Tids son :"

#: plugin.py:219 plugin.py:261
msgid "Change city"
msgstr "Byt Stad"

#: plugin.py:257
msgid "About"
msgstr "Om"

#: plugin.py:260
msgid "Enter the city name :"
msgstr "Skriv stad eller plats :"

#: plugin.py:277
msgid "Sorry no matches found"
msgstr "Ingen plats funnet"

#: plugin.py:313
msgid "Press ok to confirm"
msgstr "Tryck på OK för att bekräfta"

#: plugin.py:338
msgid "Weather forecast"
msgstr "Väderprognos"

#: plugin.py:348
msgid "World Weather Forecast"
msgstr "Världs väderprognos"

With this plugin, yes, you can´t. It has no locales. You must append the translation to sweden enigma2 translation file.
 
Well would it not be a good thing to add? edit the enigma2 language file is like doing brain surgery ;)

But i manage to fix it :) but i see some typos i have done ;)

add this code to plugin.py and locale is working

from Tools.Directories import fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
from Components.Language import language
from os import environ as os_environ
import gettext

def localeInit():
lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
gettext.bindtextdomain("BhWeather", resolveFilename(SCOPE_PLUGINS, "Extensions/BhWeather/locale"))

def _(txt):
t = gettext.dgettext("BhWeather", txt)
if t == txt:
print("[BhWeather] fallback to default translation for", txt)
t = gettext.gettext(txt)
return t

localeInit()
language.addCallback(localeInit)


bhweather-sv.jpg
 
Last edited:

AlexWilMac

Moderator
Typos are my nightmare :D
And they are soooo hidden! So, the best way (for the missing original lines, of course) is to take the msgid lines from the English version and paste into the locale.
 
Oh it was more then a typo, First i named the folder wrong "local" instead of "locale" :p

Then for some reason it was not possible to add the usual python code into the _init_.py file for locale translations.

So i hade to add it into the plugin.py file instead.
And while i was looking through the plugin code i found some minor tweaks i also added

1. Labels now translate (Weather Forecast) and (Current Temp)

2. Add green led button for the About screen so the author of the plugin get his/hers well deserved credits :)

I hate those yahoo and msn crapp weather skin packs this is a clean easy to understand weather plugin :thanks: so thanks to @meo and @Xbmc

And if i am allowed i would like to build an ipk and upload that works with OBH? if someone else like me
like this weather plugin and are missing it in OBH image

bhweather-en.jpg

bhweather-sv.jpg
 

AlexWilMac

Moderator
In OBH there's already a good plugin. There is easy to update and commit the changes.
You'll find it among OBH extensions: WeatherPlugin.
Just download the English WeatherPlugin.po from GitHub.

Code:
https://github.com/oe-alliance/enigma2-plugins/tree/master/weatherplugin
 
There you see i am such a Blackhole lover that i just have to try and make the OBH look and feel more like Blackhole :p

You know what they say about old dogs ;) I am one of those dogs...
Scared of the future :suda:
But as long as its simple and good like the BH version then all is OK

Thanks Alex :)
 

AlexWilMac

Moderator
Well... I don't remember the BH one because I probably tried just once some years ago. But, as there is one specific for OBH, I suppose it's not the case of forcing the BH one.
But, as I said, I cannot compare them.
I know that the OBH one is more useful integrated in the skins specifically designed for it (all the ones with the word "weather" in their names).
Judging from your screens, used alone is probably not so... scenic as the BH one ;)
 

AlexWilMac

Moderator
Yes, I had guessed from your previous pictures. I surely tried it under BH some years ago, then deleted because I prefer specialized websites.
Under OBH it doesn't look so but if you use one of the weather-designed skins, it's not so bad.
 
Top