Skip to content

Commit

Permalink
TMS-964-2: Update translation and format pricing.
Browse files Browse the repository at this point in the history
  • Loading branch information
aerkkilae committed Sep 4, 2023
1 parent 725c06a commit 6d3e4c4
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 41 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

- TMS-964-2: Update translation and format pricing.

## [1.46.0] - 2023-08-30

- TMS-964: Add new Eventz api and remove old one.
Expand Down
Binary file modified lang/fi.mo
Binary file not shown.
30 changes: 16 additions & 14 deletions lang/fi.po
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: TMS Theme Base\n"
"POT-Creation-Date: 2023-08-30 12:27+0300\n"
"PO-Revision-Date: 2023-08-30 12:28+0300\n"
"POT-Creation-Date: 2023-09-03 19:27+0300\n"
"PO-Revision-Date: 2023-09-03 19:27+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fi\n"
Expand Down Expand Up @@ -282,27 +282,35 @@ msgid "Price"
msgstr "Hinta"

#: lib/Eventz.php:116
msgid "Organizer"
msgstr "Järjestäjä"

#: lib/Eventz.php:118
msgid "Area"
msgstr ""

#: lib/Eventz.php:118
#: lib/Eventz.php:120
msgid "Target"
msgstr ""

#: lib/Eventz.php:120
#: lib/Eventz.php:122
msgid "Tags"
msgstr ""

#: lib/Eventz.php:124
#: lib/Eventz.php:126
msgid "Links"
msgstr "Linkit"

#: lib/Eventz.php:263
#: lib/Eventz.php:269
msgid "Additional information"
msgstr "Lisätiedot"

#: lib/Eventz.php:286
msgid "Free"
msgstr "Maksuton"

#: lib/Eventz.php:285
msgid "Additional information"
#: lib/Eventz.php:318
msgid "Additional info"
msgstr "Lisätiedot"

#: lib/Formatters/CountdownFormatter.php:80 models/strings.php:224
Expand Down Expand Up @@ -1166,12 +1174,6 @@ msgstr ""
msgid "https://geniem.fi"
msgstr ""

#~ msgid "Organizer"
#~ msgstr "Järjestäjä"

#~ msgid "Additional info"
#~ msgstr "Lisätiedot"

#~ msgid "Virtual event"
#~ msgstr "Verkkotapahtuma"

Expand Down
22 changes: 15 additions & 7 deletions lang/tms-theme-base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: TMS Theme Base\n"
"POT-Creation-Date: 2023-08-30 12:27+0300\n"
"POT-Creation-Date: 2023-09-03 19:27+0300\n"
"PO-Revision-Date: 2022-01-12 10:08+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down Expand Up @@ -282,27 +282,35 @@ msgid "Price"
msgstr ""

#: lib/Eventz.php:116
msgid "Area"
msgid "Organizer"
msgstr ""

#: lib/Eventz.php:118
msgid "Target"
msgid "Area"
msgstr ""

#: lib/Eventz.php:120
msgid "Target"
msgstr ""

#: lib/Eventz.php:122
msgid "Tags"
msgstr ""

#: lib/Eventz.php:124
#: lib/Eventz.php:126
msgid "Links"
msgstr ""

#: lib/Eventz.php:263
#: lib/Eventz.php:269
msgid "Additional information"
msgstr ""

#: lib/Eventz.php:286
msgid "Free"
msgstr ""

#: lib/Eventz.php:285
msgid "Additional information"
#: lib/Eventz.php:318
msgid "Additional info"
msgstr ""

#: lib/Formatters/CountdownFormatter.php:80 models/strings.php:224
Expand Down
53 changes: 33 additions & 20 deletions lib/Eventz.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public static function normalize_event( $event ) : array {
'location' => static::get_event_location( $event ),
'price_title' => __( 'Price', 'tms-theme-base' ),
'price' => static::get_event_price_info( $event, $lang_key ),
'provider_title' => __( 'Organizer', 'tms-theme-base' ),
'area_title' => __( 'Area', 'tms-theme-base' ),
'areas' => static::get_area_info( $event ),
'target_title' => __( 'Target', 'tms-theme-base' ),
Expand Down Expand Up @@ -253,29 +254,11 @@ public static function get_as_datetime( $value ) {
* @return array|null
*/
public static function get_event_price_info( $event ) : ?array {
if ( empty( $event ) ) {
if ( empty( $event ) || empty( $event->price ) ) {
return null;
}

$price = $event->price ?? null;

if ( empty( $price ) || $event->price->isFree ) {
$price = __( 'Free', 'tms-theme-base' );
}
else {
$min = $event->price->min;
$max = $event->price->max;

if ( $min === 0 && $max > 0 ) {
$price = $max . '';
}
elseif ( $max === 0 && $min > 0 ) {
$price = $min . '';
}
else {
$price = $min . '-' . $max . '';
}
}
$price = self::format_price( $event->price );

return [
[
Expand All @@ -290,6 +273,36 @@ public static function get_event_price_info( $event ) : ?array {
];
}

/**
* Format price.
*
* @param object $price Event price.
*
* @return string|null
*/
public static function format_price( $price ) : ?string {
if ( $price->isFree ) {
return __( 'Free', 'tms-theme-base' );
}

$formatted_price = '';

// Price data might differ.
if ( $price->min === 0 && $price->max > 0 ) {
$formatted_price = $price->max;
}

if ( $price->max === 0 && $price->min > 0 ) {
$formatted_price = $price->min;
}

if( empty ( $formatted_price ) ) {

Check failure on line 299 in lib/Eventz.php

View workflow job for this annotation

GitHub Actions / phpcs-check

Space after opening control structure is required

Check failure on line 299 in lib/Eventz.php

View workflow job for this annotation

GitHub Actions / phpcs-check

No space before opening parenthesis is prohibited

Check failure on line 299 in lib/Eventz.php

View workflow job for this annotation

GitHub Actions / phpcs-check

Space before opening parenthesis of function call prohibited
$formatted_price = $price->min . '-' . $price->max;
}

return $formatted_price . '';
}

/**
* Get area info
*
Expand Down

0 comments on commit 6d3e4c4

Please sign in to comment.