1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Make Datepicker translatable

Summary: This adds the Ablillity to translate the Content of the Date Picker. It is possible to display more than one Letter for the Day Captions.

Test Plan:
 - Change the Language in the User Preferences, make sure it translates 'S|M|T|W|T|F|S' and Months or add the following to the translation.override config to get German Translation:

```
{
    'S|M|T|W|T|F|S': 'So|Mo|Di|Mi|Do|Fr|Sa',
    'January': 'Januar',
    'February': 'Februar',
    'March': 'März',
    'May': 'Mai',
    'June': 'Juni',
    'July': 'Juli',
    'October': 'Oktober',
    'December': 'Dezember'
}
```
 - Open Datepicker on a Datefield (Edit Event or Edit for Custom Field of Type date)
 - The Day Headers and the Months should now be translated

Reviewers: O1 Blessed Committers, speck

Reviewed By: O1 Blessed Committers, speck

Subscribers: CSharp, 0, speck, tobiaswiese

Tags: #calendar

Differential Revision: https://we.phorge.it/D25016
This commit is contained in:
Leon Eckardt 2021-09-21 20:45:14 -04:00 committed by Christopher Speck
parent fd1922c763
commit b293e6ffed
3 changed files with 40 additions and 23 deletions

View file

@ -481,7 +481,7 @@ return array(
'rsrc/js/core/behavior-detect-timezone.js' => '78bc5d94', 'rsrc/js/core/behavior-detect-timezone.js' => '78bc5d94',
'rsrc/js/core/behavior-device.js' => 'ac2b1e01', 'rsrc/js/core/behavior-device.js' => 'ac2b1e01',
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '7ad020a5', 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '7ad020a5',
'rsrc/js/core/behavior-fancy-datepicker.js' => '956f3eeb', 'rsrc/js/core/behavior-fancy-datepicker.js' => 'e77fcc9d',
'rsrc/js/core/behavior-form.js' => '55d7b788', 'rsrc/js/core/behavior-form.js' => '55d7b788',
'rsrc/js/core/behavior-gesture.js' => 'b58d1a2a', 'rsrc/js/core/behavior-gesture.js' => 'b58d1a2a',
'rsrc/js/core/behavior-global-drag-and-drop.js' => '1cab0e9a', 'rsrc/js/core/behavior-global-drag-and-drop.js' => '1cab0e9a',
@ -635,7 +635,7 @@ return array(
'javelin-behavior-editengine-reorder-configs' => '4842f137', 'javelin-behavior-editengine-reorder-configs' => '4842f137',
'javelin-behavior-editengine-reorder-fields' => '0ad8d31f', 'javelin-behavior-editengine-reorder-fields' => '0ad8d31f',
'javelin-behavior-event-all-day' => '0b1bc990', 'javelin-behavior-event-all-day' => '0b1bc990',
'javelin-behavior-fancy-datepicker' => '956f3eeb', 'javelin-behavior-fancy-datepicker' => 'e77fcc9d',
'javelin-behavior-global-drag-and-drop' => '1cab0e9a', 'javelin-behavior-global-drag-and-drop' => '1cab0e9a',
'javelin-behavior-harbormaster-log' => 'b347a301', 'javelin-behavior-harbormaster-log' => 'b347a301',
'javelin-behavior-herald-rule-editor' => '0922e81d', 'javelin-behavior-herald-rule-editor' => '0922e81d',
@ -1781,13 +1781,6 @@ return array(
'javelin-vector', 'javelin-vector',
'javelin-stratcom', 'javelin-stratcom',
), ),
'956f3eeb' => array(
'javelin-behavior',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-vector',
),
'9623adc1' => array( '9623adc1' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -2174,6 +2167,13 @@ return array(
'javelin-dom', 'javelin-dom',
'phabricator-draggable-list', 'phabricator-draggable-list',
), ),
'e77fcc9d' => array(
'javelin-behavior',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-vector',
),
'e8240b50' => array( 'e8240b50' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',

View file

@ -267,9 +267,25 @@ final class AphrontFormDateControl extends AphrontFormControl {
$week_key = PhabricatorWeekStartDaySetting::SETTINGKEY; $week_key = PhabricatorWeekStartDaySetting::SETTINGKEY;
$week_start = $viewer->getUserSetting($week_key); $week_start = $viewer->getUserSetting($week_key);
$date_pht = array(
'S|M|T|W|T|F|S' => pht('S|M|T|W|T|F|S'),
'January' => pht('January'),
'February' => pht('February'),
'March' => pht('March'),
'April' => pht('April'),
'May' => pht('May'),
'June' => pht('June'),
'July' => pht('July'),
'August' => pht('August'),
'September' => pht('September'),
'October' => pht('October'),
'November' => pht('November'),
'December' => pht('December'),
);
Javelin::initBehavior('fancy-datepicker', array( Javelin::initBehavior('fancy-datepicker', array(
'format' => $this->getDateFormat(), 'format' => $this->getDateFormat(),
'weekStart' => $week_start, 'weekStart' => $week_start,
'pht' => $date_pht,
)); ));
$classes = array(); $classes = array();

View file

@ -13,6 +13,7 @@ JX.behavior('fancy-datepicker', function(config, statics) {
} }
statics.initialized = true; statics.initialized = true;
var pht = JX.phtize(config.pht);
var picker; var picker;
var anchor_node; var anchor_node;
var root; var root;
@ -262,18 +263,18 @@ JX.behavior('fancy-datepicker', function(config, statics) {
var year = valid_date.getYear() + 1900; var year = valid_date.getYear() + 1900;
var months = [ var months = [
'January', pht('January'),
'February', pht('February'),
'March', pht('March'),
'April', pht('April'),
'May', pht('May'),
'June', pht('June'),
'July', pht('July'),
'August', pht('August'),
'September', pht('September'),
'October', pht('October'),
'November', pht('November'),
'December']; pht('December')];
var buttons = [ var buttons = [
cell('\u25C0', 'm:-1', false, 'lrbutton'), cell('\u25C0', 'm:-1', false, 'lrbutton'),
@ -330,14 +331,14 @@ JX.behavior('fancy-datepicker', function(config, statics) {
var weeks = []; var weeks = [];
// First, render the weekday names. // First, render the weekday names.
var weekdays = 'SMTWTFS'; var weekdays = pht('S|M|T|W|T|F|S').split('|');
var weekday_names = []; var weekday_names = [];
var week_start = parseInt(get_week_start(), 10); var week_start = parseInt(get_week_start(), 10);
var week_end = weekdays.length + week_start; var week_end = weekdays.length + week_start;
for (var ii = week_start; ii < week_end; ii++) { for (var ii = week_start; ii < week_end; ii++) {
var index = ii%7; var index = ii%7;
weekday_names.push(cell(weekdays.charAt(index), null, false, 'day-name')); weekday_names.push(cell(weekdays[index], null, false, 'day-name'));
} }
weeks.push(JX.$N('tr', {}, weekday_names)); weeks.push(JX.$N('tr', {}, weekday_names));