mirror of
https://github.com/discourse/discourse.git
synced 2025-04-02 01:35:59 +08:00
FIX: Regression in timezone name localizations (#15761)
This also switches to using the NPM package for better build stability. And adds a clearer label in the alert that is displayed to show your current timezone (when changing timezones).
This commit is contained in:
parent
c23ccd87f8
commit
febe997bee
@ -1,25 +1,29 @@
|
||||
import ComboBoxComponent from "select-kit/components/combo-box";
|
||||
import { computed } from "@ember/object";
|
||||
|
||||
export default ComboBoxComponent.extend({
|
||||
pluginApiIdentifiers: ["timezone-input"],
|
||||
classNames: ["timezone-input"],
|
||||
nameProperty: null,
|
||||
valueProperty: null,
|
||||
|
||||
selectKitOptions: {
|
||||
filterable: true,
|
||||
allowAny: false,
|
||||
},
|
||||
|
||||
content: computed(function () {
|
||||
if (
|
||||
moment.locale() !== "en" &&
|
||||
typeof moment.tz.localizedNames === "function"
|
||||
) {
|
||||
return moment.tz.localizedNames().mapBy("value");
|
||||
} else {
|
||||
return moment.tz.names();
|
||||
}
|
||||
}),
|
||||
get nameProperty() {
|
||||
return this.isLocalized ? "name" : null;
|
||||
},
|
||||
|
||||
get valueProperty() {
|
||||
return this.isLocalized ? "value" : null;
|
||||
},
|
||||
|
||||
get content() {
|
||||
return this.isLocalized ? moment.tz.localizedNames() : moment.tz.names();
|
||||
},
|
||||
|
||||
get isLocalized() {
|
||||
return (
|
||||
moment.locale() !== "en" && typeof moment.tz.localizedNames === "function"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
@ -7,6 +7,7 @@
|
||||
"license": "GPL-2.0-only",
|
||||
"dependencies": {
|
||||
"@discourse/itsatrap": "^2.0.10",
|
||||
"@discourse/moment-timezone-names-translations": "^1.0.0",
|
||||
"@fortawesome/fontawesome-free": "5.11.2",
|
||||
"@highlightjs/cdn-assets": "^10.7.0",
|
||||
"@json-editor/json-editor": "^2.6.1",
|
||||
@ -30,7 +31,6 @@
|
||||
"markdown-it": "10.0.0",
|
||||
"moment": "2.29.1",
|
||||
"moment-timezone": "0.5.31",
|
||||
"moment-timezone-names-translations": "https://github.com/discourse/moment-timezone-names-translations",
|
||||
"pikaday": "1.8.0",
|
||||
"workbox-cacheable-response": "^4.3.1",
|
||||
"workbox-core": "^4.3.1",
|
||||
|
@ -205,7 +205,7 @@ export default Component.extend({
|
||||
|
||||
@computed("currentUserTimezone")
|
||||
formatedCurrentUserTimezone(timezone) {
|
||||
return timezone.replace("_", " ").replace("Etc/", "").split("/");
|
||||
return timezone.replace("_", " ").replace("Etc/", "").replace("/", ", ");
|
||||
},
|
||||
|
||||
@computed("formats")
|
||||
@ -398,8 +398,10 @@ export default Component.extend({
|
||||
return new Promise((resolve) => {
|
||||
loadScript("/javascripts/pikaday.js").then(() => {
|
||||
const options = {
|
||||
field: this.$(`.fake-input`)[0],
|
||||
container: this.$(`#picker-container-${this.elementId}`)[0],
|
||||
field: this.element.querySelector(".fake-input"),
|
||||
container: this.element.querySelector(
|
||||
`#picker-container-${this.elementId}`
|
||||
),
|
||||
bound: false,
|
||||
format: "YYYY-MM-DD",
|
||||
reposition: false,
|
||||
|
@ -7,7 +7,8 @@
|
||||
{{#if isValid}}
|
||||
{{#if timezoneIsDifferentFromUserTimezone}}
|
||||
<div class="preview alert alert-info">
|
||||
<b>{{formatedCurrentUserTimezone}} </b>{{currentPreview}}
|
||||
{{i18n "discourse_local_dates.create.form.current_timezone"}}
|
||||
<b>{{formatedCurrentUserTimezone}}</b>{{currentPreview}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
|
@ -262,6 +262,7 @@
|
||||
|
||||
b {
|
||||
margin-right: 0.5em;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
b + p {
|
||||
|
@ -25,6 +25,7 @@ en:
|
||||
format_title: Date format
|
||||
timezone: Timezone
|
||||
until: Until...
|
||||
current_timezone: "Current timezone:"
|
||||
recurring:
|
||||
every_day: "Every day"
|
||||
every_week: "Every week"
|
||||
|
@ -111,6 +111,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@discourse/itsatrap/-/itsatrap-2.0.10.tgz#c7e750eeb32b54e769e952c4ecc472213eb1385a"
|
||||
integrity sha512-Jn1gdiyHMGUsmUfLFf4Q7VnTAv0l7NePbegU6pKhKHEmbzV3FosGxq30fTOYgVyTS1bxqGjlA6LvQttJpv3ROw==
|
||||
|
||||
"@discourse/moment-timezone-names-translations@^1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@discourse/moment-timezone-names-translations/-/moment-timezone-names-translations-1.0.0.tgz#b22344456513d37c81baf384a41487b539b91534"
|
||||
integrity sha512-4xr1QWQ0nzmFa2ZXQgWZA+dtE/BU2ePA+qkJWPFzNpq4ZnQi8MmMMAS2285t3rc2ySMBQqYaAArmcSUiufUgRA==
|
||||
|
||||
"@ember-data/rfc395-data@^0.0.4":
|
||||
version "0.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@ember-data/rfc395-data/-/rfc395-data-0.0.4.tgz#ecb86efdf5d7733a76ff14ea651a1b0ed1f8a843"
|
||||
@ -2933,10 +2938,6 @@ module-deps@^6.2.3:
|
||||
through2 "^2.0.0"
|
||||
xtend "^4.0.0"
|
||||
|
||||
"moment-timezone-names-translations@https://github.com/discourse/moment-timezone-names-translations":
|
||||
version "0.0.0"
|
||||
resolved "https://github.com/discourse/moment-timezone-names-translations#5f576fc6355d8e636783bfb7b0214a5d74a5399d"
|
||||
|
||||
moment-timezone@0.5.31:
|
||||
version "0.5.31"
|
||||
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.31.tgz#9c40d8c5026f0c7ab46eda3d63e49c155148de05"
|
||||
|
Loading…
x
Reference in New Issue
Block a user