Skip to content

Commit

Permalink
Plasmoid updates
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkXero-dev committed Apr 17, 2024
1 parent be56a91 commit b396528
Show file tree
Hide file tree
Showing 49 changed files with 539 additions and 1,555 deletions.
6 changes: 0 additions & 6 deletions Configs/Home/.directory

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function getForecastData() {
plasmoid.configuration.longitude;
url += "/forecast/daily/7day.json";
url += "?apiKey=" + API_KEY;
url += "&language=en-US";
url += "&language=" + Qt.locale().name.replace("_","-");

if (unitsChoice === 0) {
url += "&units=m";
Expand Down Expand Up @@ -215,6 +215,7 @@ function getForecastData() {
fullDateTime.split("T")[0].split("-")[2]
);

// API returns empty string if no snow. Check for empty string.
var snowDesc = "";
if (isDay) {
snowDesc =
Expand All @@ -228,20 +229,34 @@ function getForecastData() {
: night["snow_phrase"];
}

// API does not return a thunderDesc for non-English languages. Check for null value.
var thunderDesc = "";
if (isDay) {
thunderDesc = day["thunder_enum_phrase"] !== null ? day["thunder_enum_phrase"] : "N/A"
} else {
thunderDesc = night["thunder_enum_phrase"] !== null ? night["thunder_enum_phrase"] : "N/A"
}

// API does not return a 12char weather description for non-English languages, but it always returns a 32char. Check for empty string.
var shortDesc = "";
if (isDay) {
shortDesc = day["phrase_12char"] !== "" ? day["phrase_12char"] : day["phrase_32char"]
} else {

shortDesc = night["phrase_12char"] !== "" ? night["phrase_12char"] : night["phrase_32char"]
}


forecastModel.append({
date: date,
dayOfWeek: isDay ? forecast["dow"] : "Tonight",
iconCode: isDay ? iconThemeMap[day["icon_code"]] : iconThemeMap[night["icon_code"]],
high: isDay ? forecast["max_temp"] : night["hi"],
low: forecast["min_temp"],
feelsLike: isDay ? day["hi"] : night["hi"],
shortDesc: isDay
? day["phrase_12char"]
: night["phrase_12char"],
shortDesc: shortDesc,
longDesc: isDay ? day["narrative"] : night["narrative"],
thunderDesc: isDay
? day["thunder_enum_phrase"]
: night["thunder_enum_phrase"],
thunderDesc: thunderDesc,
winDesc: isDay
? day["wind_phrase"]
: night["wind_phrase"],
Expand Down Expand Up @@ -328,7 +343,7 @@ function findIconCode() {

url += "?geocode=" + lat + "," + long;
url += "&apiKey=" + API_KEY;
url += "&language=en-US";
url += "&language=" + Qt.locale().name.replace("_","-");

if (unitsChoice === 0) {
url += "&units=m";
Expand Down Expand Up @@ -462,5 +477,3 @@ function getExtendedConditions() {
req.send();
}

/**
* Get air quality
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ import org.kde.plasma.configuration

ConfigModel {
ConfigCategory {
name: "Station"
name: i18n("Station")
icon: "flag"
source: "config/ConfigStation.qml"
}
ConfigCategory {
name: "Appearance"
name: i18n("Appearance")
icon: "preferences-desktop-color"
source: "config/ConfigAppearance.qml"
}
ConfigCategory {
name: "Units"
name: i18n("Units")
icon: "configure"
source: "config/ConfigUnits.qml"
}
ConfigCategory {
name: "Debug"
name: i18n("Debug")
icon: "preferences-other"
source: "config/ConfigDebug.qml"
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ RowLayout {
PlasmaComponents.Label {
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter

// TODO: add elide behavior since non-English descriptions can be longer
text: shortDesc
}
Kirigami.Icon {
Expand All @@ -64,7 +65,7 @@ RowLayout {
id: tooltip

mainText: longDesc
subText: "<font size='4'>" + "Feels like: " + Utils.currentTempUnit(feelsLike) + "<br/>Thunder: " + thunderDesc + "<br/>UV: " + UVDesc + "<br/>Snow: " + snowDesc + "<br/>Golf: " + golfDesc + "</font>"
subText: i18nc("Do not edit HTML tags.","<font size='4'>Feels like: %1<br/>Thunder: %2<br/>UV: %3<br/>Snow: %4<br/>Golf: %5</font>", Utils.currentTempUnit(feelsLike), thunderDesc, UVDesc, snowDesc, golfDesc)

interactive: true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ KCM.SimpleKCM {
}

PlasmaComponents.Label {
text: "Version 2.5.5"
text: "Version 0.0.9"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import org.kde.plasma.plasmoid
import org.kde.plasma.core as PlasmaCore

Button {
text: "Configure Wunderground"
text: i18n("Configure Wunderground")
icon.name: "settings"

onClicked: plasmoid.internalAction("configure").trigger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* along with this program. If not, see <http: //www.gnu.org/licenses/>.
*/

import QtQml
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
Expand Down Expand Up @@ -144,12 +145,7 @@ PlasmoidItem {

Component.onCompleted: {
//printDebug(plasmoid.containment.corona.kPackage)
//printDebug("qlocation: " + plasmoid.location)
//printDebug("qformfactor: " + plasmoid.formFactor)
//printDebug("qavailscreen: " + plasmoid.containment.availableScreenRect)
//printDebug("qcontaintype: " + plasmoid.containment.containmentType)
//printDebug("qcontainhint: " + plasmoid.containment.containmentDisplayHints)
inTray = plasmoid.containment.containmentType == 129 && plasmoid.formFactor == 2
inTray = plasmoid.containment.containmentType == 129 && plasmoid.formFactor == 2

plasmoid.configurationRequiredReason = i18n("Set the weather station to pull data from.")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"KPackageStructure": "Plasma/Applet",
"KPlugin": {
"Authors": [
{
"Email": "[email protected]",
"Name": "k-donn"
}
],
"Category": "Environment and Weather",
"Description": "Wunderground Personal Weather Station viewer",
"Description[de_DE]": "Wunderground Personal Weather Station viewer",
"Description[es_ES]": "Visor de la estación meteorológica personal Wunderground",
"Description[fr_FR]": "Visualisation de station météorologique personnelle Wunderground",
"Description[ja_JP]": "Wunderground Personal Weather Station viewer",
"Description[nl_NL]": "Wunderground - Bekijk je eigen weerstation",
"Description[ru_RU]": "Программа просмотра персональных метеостанций Wunderground",
"Icon": "weather-clear",
"Id": "com.github.k-donn.plasmoid-wunderground",
"License": "GPL2-or-later",
"Name": "Wunderground",
"Name[de_DE]": "Wunderground",
"Name[es_ES]": "Wunderground",
"Name[fr_FR]": "Wunderground",
"Name[ja_JP]": "Wunderground",
"Name[nl_NL]": "Wunderground",
"Name[ru_RU]": "Wunderground",
"Version": "0.0.6",
"Website": "https://github.com/k-donn/plasmoid-wunderground"
},
"X-KDE-ParentApp": "",
"X-Plasma-API-Minimum-Version": "6.0",
"X-Plasma-NotificationArea": "true",
"X-Plasma-NotificationAreaCategory": "SystemServices"
"KPackageStructure": "Plasma/Applet",
"KPlugin": {
"Authors": [
{
"Email": "[email protected]",
"Name": "k-donn"
}
],
"Category": "Environment and Weather",
"Description": "Wunderground Personal Weather Station viewer",
"Description[de_DE]": "Wunderground Personal Weather Station viewer",
"Description[es_ES]": "Visor de la estación meteorológica personal Wunderground",
"Description[fr_FR]": "Visualisation de station météorologique personnelle Wunderground",
"Description[ja_JP]": "Wunderground Personal Weather Station viewer",
"Description[nl_NL]": "Wunderground - Bekijk je eigen weerstation",
"Description[ru_RU]": "Программа просмотра персональных метеостанций Wunderground",
"Icon": "weather-clear",
"Id": "com.github.k-donn.plasmoid-wunderground",
"License": "GPL2-or-later",
"Name": "Wunderground",
"Name[de_DE]": "Wunderground",
"Name[es_ES]": "Wunderground",
"Name[fr_FR]": "Wunderground",
"Name[ja_JP]": "Wunderground",
"Name[nl_NL]": "Wunderground",
"Name[ru_RU]": "Wunderground",
"Version": "0.0.9",
"Website": "https://github.com/k-donn/plasmoid-wunderground"
},
"X-KDE-ParentApp": "",
"X-Plasma-API-Minimum-Version": "6.0",
"X-Plasma-NotificationArea": "true",
"X-Plasma-NotificationAreaCategory": "SystemServices"
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,55 @@
> Version 7 of Zren's i18n scripts.
# Translate

With KDE Frameworks v5.37 and above, translations are bundled with the `*.plasmoid` file downloaded from the store.
## Status

## Install Translations
| Locale | Lines | % Done|
|----------|---------|-------|
| Template | 50 | |
| ru_RU | 44/50 | 88% |
| nl_NL | 44/50 | 88% |
| es_ES | 44/50 | 88% |
| de_DE | 48/50 | 96% |
| ja_JP | 44/50 | 88% |
| fr_FR | 44/50 | 88% |

Go to `~/.local/share/plasma/plasmoids/com.github.k-donn.plasmoid-wunderground/translate/` and run `sh ./build --restartplasma`.

## New Translations

1. Fill out [`template.pot`](template.pot) with your translations then open a [new issue](https://github.com/k-donn/plasmoid-wunderground/issues/new), name the file `spanish.txt`, attach the txt file to the issue (drag and drop).
* Fill out [`template.pot`](template.pot) with your translations then open a [new issue](https://github.com/k-donn/plasmoid-wunderground/issues/new), name the file `spanish.txt`, attach the txt file to the issue (drag and drop).

Or if you know how to make a pull request

1. Copy the `template.pot` file and name it your locale's code (Eg: `en`/`de`/`fr`) with the extension `.po`. Then fill out all the `msgstr ""`.
* Copy the `template.pot` file and name it your locale's code (Eg: `en`/`de`/`fr`) with the extension `.po`. Then fill out all the `msgstr ""`.
* Your region's locale code can be found at: https://stackoverflow.com/questions/3191664/list-of-all-locales-and-their-short-codes/28357857#28357857

## Scripts

- `sh ./merge` will parse the `i18n()` calls in the `*.qml` files and write it to the `template.pot` file. Then it will merge any changes into the `*.po` language files.
- `sh ./build` will convert the `*.po` files to it's binary `*.mo` version and move it to `contents/locale/...` which will bundle the translations in the `*.plasmoid` without needing the user to manually install them.
- `sh ./plasmoidlocaletest` will run `./build` then `plasmoidviewer` (part of `plasma-sdk`).
Zren's `kpac` script can easily run the `gettext` commands for you, parsing the `metadata.json` and filling out any placeholders for you. `kpac` can be [downloaded here](https://github.com/Zren/plasma-applet-lib/blob/master/kpac) and should be placed at `~/Code/plasmoid-widgetname/kpac` to edit translations at `~/Code/plasmoid-widgetname/package/translate/`.

## Links

- https://zren.github.io/kde/docs/widget/#translations-i18n
- https://techbase.kde.org/Development/Tutorials/Localization/i18n_Build_Systems
- https://api.kde.org/frameworks/ki18n/html/prg_guide.html
* `python3 ./kpac i18n` will parse the `i18n()` calls in the `*.qml` files and write it to the `template.pot` file. Then it will merge any changes into the `*.po` language files. Then it converts the `*.po` files to it's binary `*.mo` version and move it to `contents/locale/...` which will bundle the translations in the `*.plasmoid` without needing the user to manually install them.
* `python3 ./kpac localetest` will convert the `.po` to the `*.mo` files then run `plasmoidviewer` (part of `plasma-sdk`).

## Examples
## How it works

- https://l10n.kde.org/stats/gui/trunk-kf5/team/fr/plasma-desktop/
- https://github.com/psifidotos/nowdock-plasmoid/tree/master/po
- https://github.com/kotelnik/plasma-applet-redshift-control/tree/master/translations
Since KDE Frameworks v5.37, translations can be bundled with the zipped `*.plasmoid` file downloaded from the store.

| Locale | Lines | % Done|
|----------|---------|-------|
| Template | 44 | |
| de_DE | 44/44 | 100% |
| es_ES | 44/44 | 100% |
| fr_FR | 44/44 | 100% |
| ja_JP | 44/44 | 100% |
| nl_NL | 44/44 | 100% |
| ru_RU | 44/44 | 100% |
* `xgettext` extracts the messages from the source code into a `template.pot`.
* Translators copy the `template.pot` to `fr.po` to translate the French language.
* When the source code is updated, we use `msgmerge` to update the `fr.po` based on the updated `template.pot`.
* When testing or releasing the widget, we convert the `.po` files to their binary `.mo` form with `msgfmt`.

The binary `.mo` translation files are placed in `package/contents/locale/` so you may want to add `*.mo` to your `.gitignore`.

```
package/contents/locale/fr/LC_MESSAGES/plasma_applet_com.github.k-donn.plasmoid-wunderground.mo
```

## Links

* https://develop.kde.org/docs/plasma/widget/translations-i18n/
* https://l10n.kde.org/stats/gui/trunk-kf5/team/fr/plasma-desktop/
* https://techbase.kde.org/Development/Tutorials/Localization/i18n_Build_Systems
* https://api.kde.org/frameworks/ki18n/html/prg_guide.html

> Version 8 of [Zren's i18n scripts](https://github.com/Zren/plasma-applet-lib).

This file was deleted.

Loading

0 comments on commit b396528

Please sign in to comment.