PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
fluent-cart / app / Services / Translations / TransStrings.php

TransStrings.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.5, at app/Services/Translations/TransStrings.php

483 lines 27.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Services\Translations;
4
5 use FluentCart\App\Services\DateTime\DateFormatter;
6
7 class TransStrings
8 {
9 public static function getStrings(): array
10 {
11 $translations = require 'admin-translation.php';
12 return apply_filters("fluent_cart/admin_translations", $translations, []);
13 }
14
15 public static function blockStrings(): array
16 {
17 $translations = require 'block-editor-translation.php';
18 return apply_filters("fluent_cart/blocks_translations", $translations, []);
19 }
20
21
22 public static function getShopAppBlockEditorString(): array
23 {
24
25 return [
26 'Also search in Content' => _x('Also search in Content', 'Shop App Block Editor', 'fluent-cart'),
27 'Apply Filter' => _x('Apply Filter', 'Shop App Block Editor', 'fluent-cart'),
28 // 'Add to Cart' => _x('Add to Cart', 'Shop App Block Editor', 'fluent-cart'),
29 'Default' => _x('Default', 'Shop App Block Editor', 'fluent-cart'),
30 'Display Name For Filter' => _x('Display Name For Filter', 'Shop App Block Editor', 'fluent-cart'),
31 'Enable Default Filtering' => _x('Enable Default Filtering', 'Shop App Block Editor', 'fluent-cart'),
32 'Enable Filtering' => _x('Enable Filtering', 'Shop App Block Editor', 'fluent-cart'),
33 'Enable' => _x('Enable', 'Shop App Block Editor', 'fluent-cart'),
34 'Enabled?' => _x('Enabled?', 'Shop App Block Editor', 'fluent-cart'),
35 'Filter Option' => _x('Filter Option', 'Shop App Block Editor', 'fluent-cart'),
36 'Grid' => _x('Grid', 'Shop App Block Editor', 'fluent-cart'),
37 'List' => _x('List', 'Shop App Block Editor', 'fluent-cart'),
38 'Numbers' => _x('Numbers', 'Shop App Block Editor', 'fluent-cart'),
39 'Option' => _x('Option', 'Shop App Block Editor', 'fluent-cart'),
40 'Paginator' => _x('Paginator', 'Shop App Block Editor', 'fluent-cart'),
41 'Per Page' => _x('Per Page', 'Shop App Block Editor', 'fluent-cart'),
42 'Product Box Grid Size' => _x('Product Box Grid Size', 'Shop App Block Editor', 'fluent-cart'),
43 'Product Categories' => _x('Product Categories', 'Shop App Block Editor', 'fluent-cart'),
44 'Product Grid Size' => _x('Product Grid Size', 'Shop App Block Editor', 'fluent-cart'),
45 'Product Types' => _x('Product Types', 'Shop App Block Editor', 'fluent-cart'),
46 'Product' => _x('Product', 'Shop App Block Editor', 'fluent-cart'),
47 'Range Filter Only works in pages.' => _x('Range Filter Only works in pages.', 'Shop App Block Editor', 'fluent-cart'),
48 'Scroll' => _x('Scroll', 'Shop App Block Editor', 'fluent-cart'),
49 'Search Grid Size' => _x('Search Grid Size', 'Shop App Block Editor', 'fluent-cart'),
50 'Search' => _x('Search', 'Shop App Block Editor', 'fluent-cart'),
51 'View mode' => _x('View mode', 'Shop App Block Editor', 'fluent-cart'),
52 'Wildcard Filter' => _x('Wildcard Filter', 'Shop App Block Editor', 'fluent-cart'),
53
54 'Primary' => _x('Primary', 'Shop App Block Editor', 'fluent-cart'),
55 'Product Heading' => _x('Product Heading', 'Shop App Block Editor', 'fluent-cart'),
56 'Text' => _x('Text', 'Shop App Block Editor', 'fluent-cart'),
57 'Border' => _x('Border', 'Shop App Block Editor', 'fluent-cart'),
58 'Badge Count Background' => _x('Badge Count Background', 'Shop App Block Editor', 'fluent-cart'),
59 'Badge Count' => _x('Badge Count', 'Shop App Block Editor', 'fluent-cart'),
60 'Badge Count Border' => _x('Badge Count Border', 'Shop App Block Editor', 'fluent-cart'),
61
62
63 'Background' => _x('Background', 'Shop App Block Editor', 'fluent-cart'),
64 'Input Border' => _x('Input Border', 'Shop App Block Editor', 'fluent-cart'),
65 'Input Focus Border' => _x('Input Focus Border', 'Shop App Block Editor', 'fluent-cart'),
66 'Heading' => _x('Heading', 'Shop App Block Editor', 'fluent-cart'),
67 'Label' => _x('Label', 'Shop App Block Editor', 'fluent-cart'),
68 'Item Border' => _x('Item Border', 'Shop App Block Editor', 'fluent-cart'),
69 'Reset Button Bg' => _x('Reset Button Bg', 'Shop App Block Editor', 'fluent-cart'),
70 'Reset Button' => _x('Reset Button', 'Shop App Block Editor', 'fluent-cart'),
71 'Reset Button Border' => _x('Reset Button Border', 'Shop App Block Editor', 'fluent-cart'),
72 'Reset Button Hover Bg' => _x('Reset Button Hover Bg', 'Shop App Block Editor', 'fluent-cart'),
73 'Reset Button Hover' => _x('Reset Button Hover', 'Shop App Block Editor', 'fluent-cart'),
74 'Reset Button Hover Border' => _x('Reset Button Hover Border', 'Shop App Block Editor', 'fluent-cart'),
75 'Checkbox' => _x('Checkbox', 'Shop App Block Editor', 'fluent-cart'),
76 'Checkbox Active' => _x('Checkbox Active', 'Shop App Block Editor', 'fluent-cart'),
77 'Checkmark Bg' => _x('Checkmark Bg', 'Shop App Block Editor', 'fluent-cart'),
78 'Checkmark Border' => _x('Checkmark Border', 'Shop App Block Editor', 'fluent-cart'),
79 'Checkmark Active Bg' => _x('Checkmark Active Bg', 'Shop App Block Editor', 'fluent-cart'),
80 'Checkmark Active Border' => _x('Checkmark Active Border', 'Shop App Block Editor', 'fluent-cart'),
81 'Checkmark After Border' => _x('Checkmark After Border', 'Shop App Block Editor', 'fluent-cart'),
82 'Range Slider Connect Bg' => _x('Range Slider Connect Bg', 'Shop App Block Editor', 'fluent-cart'),
83
84 ];
85 }
86
87 public static function getCustomerProfileString(): array
88 {
89 $translations = require 'customer-profile-translation.php';
90 return apply_filters("fluent_cart/customer_profile_translations", $translations, []);
91 }
92
93 public static function singleProductPageString(): array
94 {
95 return [
96 'In Stock' => _x('In Stock', 'Single Product Page', 'fluent-cart'),
97 'Out Of Stock' => _x('Out Of Stock', 'Single Product Page', 'fluent-cart'),
98 'Package' => _x('Package', 'Single Product Page', 'fluent-cart'),
99 'Dimensions' => _x('Dimensions', 'Single Product Page', 'fluent-cart'),
100 'Weight' => _x('Weight', 'Single Product Page', 'fluent-cart'),
101 'Shipping Weight' => _x('Shipping Weight', 'Single Product Page', 'fluent-cart'),
102 ];
103 }
104
105 public static function checkoutPageString()
106 {
107 $translations = require 'checkout-translation.php';
108 return apply_filters("fluent_cart/checkout_translations", $translations, []);
109 }
110
111 public static function paymentsString()
112 {
113 $translations = require 'payments-translation.php';
114 return apply_filters("fluent_cart/payments_translations", $translations, []);
115 }
116
117 public static function elStrings(): array
118 {
119 return [
120 'name' => get_locale(),
121 'el' => [
122 'breadcrumb' => [
123 'label' => __('Breadcrumb', 'fluent-cart'),
124 ],
125 'colorpicker' => [
126 'confirm' => __('OK', 'fluent-cart'),
127 'clear' => __('Clear', 'fluent-cart'),
128 'defaultLabel' => __('color picker', 'fluent-cart'),
129 'description' => __('current color is {color}. press enter to select a new color.', 'fluent-cart'),
130 'alphaLabel' => __('pick alpha value', 'fluent-cart'),
131 'alphaDescription' => __('alpha {alpha}, current color is {color}', 'fluent-cart'),
132 'hueLabel' => __('pick hue value', 'fluent-cart'),
133 'hueDescription' => __('hue {hue}, current color is {color}', 'fluent-cart'),
134 'svLabel' => __('pick saturation and brightness value', 'fluent-cart'),
135 'svDescription' => __('saturation {saturation}, brightness {brightness}, current color is {color}', 'fluent-cart'),
136 'predefineDescription' => __('select {value} as the color', 'fluent-cart'),
137 ],
138 'datepicker' => [
139 'now' => __('Now', 'fluent-cart'),
140 'today' => __('Today', 'fluent-cart'),
141 'cancel' => __('Cancel', 'fluent-cart'),
142 'clear' => __('Clear', 'fluent-cart'),
143 'confirm' => __('OK', 'fluent-cart'),
144 'dateTablePrompt' => __('Use the arrow keys and enter to select the day of the month', 'fluent-cart'),
145 'monthTablePrompt' => __('Use the arrow keys and enter to select the month', 'fluent-cart'),
146 'yearTablePrompt' => __('Use the arrow keys and enter to select the year', 'fluent-cart'),
147 'selectedDate' => __('Selected date', 'fluent-cart'),
148 'selectDate' => __('Select date', 'fluent-cart'),
149 'selectTime' => __('Select time', 'fluent-cart'),
150 'startDate' => __('Start Date', 'fluent-cart'),
151 'startTime' => __('Start Time', 'fluent-cart'),
152 'endDate' => __('End Date', 'fluent-cart'),
153 'endTime' => __('End Time', 'fluent-cart'),
154 'prevYear' => __('Previous Year', 'fluent-cart'),
155 'nextYear' => __('Next Year', 'fluent-cart'),
156 'prevMonth' => __('Previous Month', 'fluent-cart'),
157 'nextMonth' => __('Next Month', 'fluent-cart'),
158 'year' => __('', 'fluent-cart'),
159 'month1' => __('January', 'fluent-cart'),
160 'month2' => __('February', 'fluent-cart'),
161 'month3' => __('March', 'fluent-cart'),
162 'month4' => __('April', 'fluent-cart'),
163 'month5' => __('May', 'fluent-cart'),
164 'month6' => __('June', 'fluent-cart'),
165 'month7' => __('July', 'fluent-cart'),
166 'month8' => __('August', 'fluent-cart'),
167 'month9' => __('September', 'fluent-cart'),
168 'month10' => __('October', 'fluent-cart'),
169 'month11' => __('November', 'fluent-cart'),
170 'month12' => __('December', 'fluent-cart'),
171 'weeks' => [
172 'sun' => __('Sun', 'fluent-cart'),
173 'mon' => __('Mon', 'fluent-cart'),
174 'tue' => __('Tue', 'fluent-cart'),
175 'wed' => __('Wed', 'fluent-cart'),
176 'thu' => __('Thu', 'fluent-cart'),
177 'fri' => __('Fri', 'fluent-cart'),
178 'sat' => __('Sat', 'fluent-cart'),
179 ],
180 'weeksFull' => [
181 'sun' => __('Sunday', 'fluent-cart'),
182 'mon' => __('Monday', 'fluent-cart'),
183 'tue' => __('Tuesday', 'fluent-cart'),
184 'wed' => __('Wednesday', 'fluent-cart'),
185 'thu' => __('Thursday', 'fluent-cart'),
186 'fri' => __('Friday', 'fluent-cart'),
187 'sat' => __('Saturday', 'fluent-cart'),
188 ],
189 'months' => [
190 'jan' => __('Jan', 'fluent-cart'),
191 'feb' => __('Feb', 'fluent-cart'),
192 'mar' => __('Mar', 'fluent-cart'),
193 'apr' => __('Apr', 'fluent-cart'),
194 'may' => __('May', 'fluent-cart'),
195 'jun' => __('Jun', 'fluent-cart'),
196 'jul' => __('Jul', 'fluent-cart'),
197 'aug' => __('Aug', 'fluent-cart'),
198 'sep' => __('Sep', 'fluent-cart'),
199 'oct' => __('Oct', 'fluent-cart'),
200 'nov' => __('Nov', 'fluent-cart'),
201 'dec' => __('Dec', 'fluent-cart'),
202 ],
203 ],
204 'inputNumber' => [
205 'decrease' => __('decrease number', 'fluent-cart'),
206 'increase' => __('increase number', 'fluent-cart'),
207 ],
208 'select' => [
209 'loading' => __('Loading', 'fluent-cart'),
210 'noMatch' => __('No matching data', 'fluent-cart'),
211 'noData' => __('No data', 'fluent-cart'),
212 'placeholder' => __('Select', 'fluent-cart'),
213 ],
214 'mention' => [
215 'loading' => __('Loading', 'fluent-cart'),
216 ],
217 'dropdown' => [
218 'toggleDropdown' => __('Toggle Dropdown', 'fluent-cart'),
219 ],
220 'cascader' => [
221 'noMatch' => __('No matching data', 'fluent-cart'),
222 'loading' => __('Loading', 'fluent-cart'),
223 'placeholder' => __('Select', 'fluent-cart'),
224 'noData' => __('No data', 'fluent-cart'),
225 ],
226 'pagination' => [
227 'goto' => __('Go to', 'fluent-cart'),
228 'pagesize' => __('/page', 'fluent-cart'),
229 'total' => __('Total {total}', 'fluent-cart'),
230 'pageClassifier' => __('', 'fluent-cart'),
231 'page' => __('Page', 'fluent-cart'),
232 'prev' => __('Go to previous page', 'fluent-cart'),
233 'next' => __('Go to next page', 'fluent-cart'),
234 'currentPage' => __('page {pager}', 'fluent-cart'),
235 'prevPages' => __('Previous {pager} pages', 'fluent-cart'),
236 'nextPages' => __('Next {pager} pages', 'fluent-cart'),
237 //'deprecationWarning' => __('Deprecated usages detected, please refer to the el-pagination documentation for more details', 'fluent-cart'),
238 ],
239 'dialog' => [
240 'close' => __('Close this dialog', 'fluent-cart'),
241 ],
242 'drawer' => [
243 'close' => __('Close this drawer', 'fluent-cart'),
244 ],
245 'messagebox' => [
246 'title' => __('Message', 'fluent-cart'),
247 'confirm' => __('OK', 'fluent-cart'),
248 'cancel' => __('Cancel', 'fluent-cart'),
249 'error' => __('Illegal input', 'fluent-cart'),
250 'close' => __('Close this dialog', 'fluent-cart'),
251 ],
252 'upload' => [
253 'deleteTip' => __('press delete to remove', 'fluent-cart'),
254 'delete' => __('Delete', 'fluent-cart'),
255 'preview' => __('Preview', 'fluent-cart'),
256 'continue' => __('Continue', 'fluent-cart'),
257 ],
258 'slider' => [
259 'defaultLabel' => __('slider between {min} and {max}', 'fluent-cart'),
260 'defaultRangeStartLabel' => __('pick start value', 'fluent-cart'),
261 'defaultRangeEndLabel' => __('pick end value', 'fluent-cart'),
262 ],
263 'table' => [
264 'emptyText' => __('No Data', 'fluent-cart'),
265 'confirmFilter' => __('Confirm', 'fluent-cart'),
266 'resetFilter' => __('Reset', 'fluent-cart'),
267 'clearFilter' => __('All', 'fluent-cart'),
268 'sumText' => __('Sum', 'fluent-cart'),
269 ],
270 'tour' => [
271 'next' => __('Next', 'fluent-cart'),
272 'previous' => __('Previous', 'fluent-cart'),
273 'finish' => __('Finish', 'fluent-cart'),
274 'close' => __('Close this dialog', 'fluent-cart'),
275 ],
276 'tree' => [
277 'emptyText' => __('No Data', 'fluent-cart'),
278 ],
279 'transfer' => [
280 'noMatch' => __('No matching data', 'fluent-cart'),
281 'noData' => __('No data', 'fluent-cart'),
282 'titles' => [__('List 1', 'fluent-cart'), __('List 2', 'fluent-cart')],
283 'filterPlaceholder' => __('Enter keyword', 'fluent-cart'),
284 'noCheckedFormat' => __('{total} items', 'fluent-cart'),
285 'hasCheckedFormat' => __('{checked}/{total} checked', 'fluent-cart'),
286 ],
287 'image' => [
288 'error' => __('FAILED', 'fluent-cart'),
289 ],
290 'pageHeader' => [
291 'title' => __('Back', 'fluent-cart'),
292 ],
293 'popconfirm' => [
294 'confirmButtonText' => __('Yes', 'fluent-cart'),
295 'cancelButtonText' => __('No', 'fluent-cart'),
296 ],
297 'carousel' => [
298 'leftArrow' => __('Carousel arrow left', 'fluent-cart'),
299 'rightArrow' => __('Carousel arrow right', 'fluent-cart'),
300 'indicator' => __('Carousel switch to index {index}', 'fluent-cart'),
301 ],
302 ],
303 ];
304 }
305
306 /**
307 * Names and formats for every date FluentCart renders, PHP and JS alike.
308 *
309 * One filter covers the whole map: the month/weekday names, and the
310 * formats derived from the store's WordPress date/time settings. Formats
311 * are PHP date() strings -- the dialect Settings > General shows and
312 * get_option() returns; the SPA payload converts them to Day.js tokens.
313 *
314 * The NAMES follow the same source setting as the formats. On 'wordpress'
315 * they come from $wp_locale -- the exact arrays wp_date() renders with --
316 * so the PHP side and the SPA cannot disagree about what August is called.
317 * They used to come from FluentCart's own text domain while PHP rendered
318 * through wp_date(), so one locale produced two answers:
319 *
320 * PHP wp_date('M') -> 'Aout' (WP core pack)
321 * JS _x('Aug', 'monthsShort', ...) -> 'Aug' (untranslated)
322 *
323 * and fluent-cart ships only a .pot, so the JS side was English on any
324 * store that had not sourced its own catalogue. $wp_locale also gets the
325 * hard cases right for free: German abbreviations keep their trailing
326 * period ('Aug.') and the four months German never abbreviates come back
327 * in full ('Marz', 'Mai', 'Juni', 'Juli').
328 *
329 * On 'fluent_cart' the text-domain names stay, because that source exists
330 * to reproduce what each side rendered before these settings landed.
331 *
332 * Cached per request AND per locale: DateFormatter reads this for every
333 * date it renders, and rebuilding ~30 gettext lookups inside a table loop
334 * is wasted work -- but the names now vary with the locale, so a request
335 * that switches locale (switch_to_locale() in a per-recipient mailer, a
336 * multilingual plugin) must not be served the first locale's month names.
337 */
338 public static function dateTimeStrings(bool $refresh = false): array
339 {
340 static $cached = [];
341
342 $locale = determine_locale();
343
344 if (!$refresh && isset($cached[$locale])) {
345 return $cached[$locale];
346 }
347
348 $strings = [
349 'weekdays' => array(
350 'sunday' => _x('Sunday', 'weekdays', 'fluent-cart'),
351 'monday' => _x('Monday', 'weekdays', 'fluent-cart'),
352 'tuesday' => _x('Tuesday', 'weekdays', 'fluent-cart'),
353 'wednesday' => _x('Wednesday', 'weekdays', 'fluent-cart'),
354 'thursday' => _x('Thursday', 'weekdays', 'fluent-cart'),
355 'friday' => _x('Friday', 'weekdays', 'fluent-cart'),
356 'saturday' => _x('Saturday', 'weekdays', 'fluent-cart'),
357 ),
358 'months' => array(
359 'January' => _x('January', 'months', 'fluent-cart'),
360 'February' => _x('February', 'months', 'fluent-cart'),
361 'March' => _x('March', 'months', 'fluent-cart'),
362 'April' => _x('April', 'months', 'fluent-cart'),
363 'May' => _x('May', 'months', 'fluent-cart'),
364 'June' => _x('June', 'months', 'fluent-cart'),
365 'July' => _x('July', 'months', 'fluent-cart'),
366 'August' => _x('August', 'months', 'fluent-cart'),
367 'September' => _x('September', 'months', 'fluent-cart'),
368 'October' => _x('October', 'months', 'fluent-cart'),
369 'November' => _x('November', 'months', 'fluent-cart'),
370 'December' => _x('December', 'months', 'fluent-cart')
371 ),
372 'weekdaysShort' => array(
373 'sun' => _x('Sun', 'weekdaysShort', 'fluent-cart'),
374 'mon' => _x('Mon', 'weekdaysShort', 'fluent-cart'),
375 'tue' => _x('Tue', 'weekdaysShort', 'fluent-cart'),
376 'wed' => _x('Wed', 'weekdaysShort', 'fluent-cart'),
377 'thu' => _x('Thu', 'weekdaysShort', 'fluent-cart'),
378 'fri' => _x('Fri', 'weekdaysShort', 'fluent-cart'),
379 'sat' => _x('Sat', 'weekdaysShort', 'fluent-cart')
380 ),
381 'monthsShort' => array(
382 'jan' => _x('Jan', 'monthsShort', 'fluent-cart'),
383 'feb' => _x('Feb', 'monthsShort', 'fluent-cart'),
384 'mar' => _x('Mar', 'monthsShort', 'fluent-cart'),
385 'apr' => _x('Apr', 'monthsShort', 'fluent-cart'),
386 'may' => _x('May', 'monthsShort', 'fluent-cart'),
387 'jun' => _x('Jun', 'monthsShort', 'fluent-cart'),
388 'jul' => _x('Jul', 'monthsShort', 'fluent-cart'),
389 'aug' => _x('Aug', 'monthsShort', 'fluent-cart'),
390 'sep' => _x('Sep', 'monthsShort', 'fluent-cart'),
391 'oct' => _x('Oct', 'monthsShort', 'fluent-cart'),
392 'nov' => _x('Nov', 'monthsShort', 'fluent-cart'),
393 'dec' => _x('Dec', 'monthsShort', 'fluent-cart')
394 ),
395 'am' => __('AM', 'fluent-cart'),
396 'pm' => __('PM', 'fluent-cart'),
397 'numericSystem' => _x('0_1_2_3_4_5_6_7_8_9', 'numeric system - Sequence must need to maintained', 'fluent-cart'),
398 'formats' => DateFormatter::defaultFormats(),
399 // The bundle carries its own legacy literals, which are not the same
400 // as PHP's ('h:mm A' against 'h:i A' -- unpadded against padded). On
401 // the FluentCart source each side must reproduce its OWN past output,
402 // so the bundle needs to know which source is active rather than just
403 // reading the converted formats above.
404 'formats_source' => DateFormatter::usesWordPressFormats() ? 'wordpress' : 'fluent_cart',
405 // Read by the admin bundle and the customer dashboard, which pick a
406 // Day.js timezone from this rather than always rendering in the
407 // browser's. 'site' is only consulted when source is 'wordpress'.
408 'timezone' => array(
409 'source' => DateFormatter::usesWordPressTimezone() ? 'wordpress' : 'fluent_cart',
410 'site' => wp_timezone_string(),
411 ),
412 ];
413
414 if (DateFormatter::usesWordPressFormats()) {
415 $strings = static::applyWordPressLocaleNames($strings);
416 }
417
418 return ($cached[$locale] = apply_filters('fluent_cart/date_time_strings', $strings));
419 }
420
421 /**
422 * Swap the text-domain month/weekday names for WordPress core's own.
423 *
424 * $wp_locale is what wp_date() renders with, so taking the names from the
425 * same object is what makes the PHP and JS sides agree by construction
426 * rather than by two catalogues happening to match.
427 *
428 * The KEYS are left exactly as built above. The SPA reads these maps by
429 * position (Object.values() against an English fallback list, see
430 * localeNames() in utils/dateFormats.js), and other consumers read them by
431 * key, so only the values may change here.
432 *
433 * Degrades to the text-domain names if $wp_locale is missing or shaped
434 * unexpectedly -- this runs on every rendered date and must never fatal.
435 *
436 * @param array<string, mixed> $strings
437 * @return array<string, mixed>
438 */
439 protected static function applyWordPressLocaleNames(array $strings): array
440 {
441 global $wp_locale;
442
443 if (!($wp_locale instanceof \WP_Locale)) {
444 return $strings;
445 }
446
447 // get_weekday() is 0-indexed from Sunday; get_month() takes '01'-'12'.
448 $weekdayIndex = 0;
449 foreach ($strings['weekdays'] as $key => $unused) {
450 $name = $wp_locale->get_weekday($weekdayIndex);
451 if ($name !== '') {
452 $strings['weekdays'][$key] = $name;
453 // The abbreviation is looked up BY the full name, so it has to
454 // be resolved from $wp_locale's own name, not from our key.
455 if (isset($strings['weekdaysShort'][substr($key, 0, 3)])) {
456 $strings['weekdaysShort'][substr($key, 0, 3)] = $wp_locale->get_weekday_abbrev($name);
457 }
458 }
459 $weekdayIndex++;
460 }
461
462 $monthIndex = 1;
463 foreach ($strings['months'] as $key => $unused) {
464 $name = $wp_locale->get_month(str_pad((string)$monthIndex, 2, '0', STR_PAD_LEFT));
465 if ($name !== '') {
466 $strings['months'][$key] = $name;
467 $shortKey = strtolower(substr($key, 0, 3));
468 if (isset($strings['monthsShort'][$shortKey])) {
469 $strings['monthsShort'][$shortKey] = $wp_locale->get_month_abbrev($name);
470 }
471 }
472 $monthIndex++;
473 }
474
475 $am = $wp_locale->get_meridiem('AM');
476 $pm = $wp_locale->get_meridiem('PM');
477 $strings['am'] = $am !== '' ? $am : $strings['am'];
478 $strings['pm'] = $pm !== '' ? $pm : $strings['pm'];
479
480 return $strings;
481 }
482 }
483