Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

日付のフォーマットの多言語対応 #4232

Merged
merged 6 commits into from
May 31, 2020

Conversation

biga816
Copy link
Contributor

@biga816 biga816 commented May 17, 2020

👏 解決する issue / Resolved Issues

📝 関連する issue / Related Issues

  • なし

⛏ 変更内容 / Details of Changes

日付に関連するところを全て多言語対応しまいた。

  • components/AgencyBarChart.vue
  • components/DataView.vue
  • components/PositiveRateMixedChart.vue
  • components/TimeBarChart.vue
  • components/TimeStackedBarChart.vue
  • components/WhatsNew.vue
  • components/cards/AgencyCard.vue
  • components/cards/ConfirmedCasesAttributesCard.vue
  • components/cards/ConfirmedCasesByMunicipalitiesCard.vue
  • components/cards/MetroCard.vue
  • nuxt-i18n.config.ts
  • pages/index.vue
  • utils/formatData.ts
  • utils/formatGraph.ts
  • utils/formatTable.ts

📸 スクリーンショット / Screenshots

都内の最新感染動向___東京都_新型コロナウイルス感染症対策サイト

都内の最新感染動向___東京都_新型コロナウイルス感染症対策サイト

全画面_2020_05_18_2_27

全画面_2020_05_18_2_29

※全画面キャプチャすると多くなるので一部抜粋。

Comment on lines +119 to +123
chartData: Object,
date: {
type: String,
default: ''
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

親コンポーネントからデータを渡されているのにも関わらず使用していなかったため追加。

Comment on lines +435 to +437
.text-nowrap {
white-space: nowrap;
}
Copy link
Contributor Author

@biga816 biga816 May 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

表の中で変に日付が改行されしまうので、改行されないようにする共通のスタイルを追加。

Comment on lines +33 to +38
ja: dateTimeFormatsCommon,
en: dateTimeFormatsCommon,
'zh-cn': dateTimeFormatsCommon,
'zh-tw': dateTimeFormatsCommon,
ko: dateTimeFormatsCommon,
'ja-basic': dateTimeFormatsCommon
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

いったん全ての言語で共通の設定とした。

Comment on lines 1 to 18
export const getComplementedDate = (dateString: string): string => {
const dates = dateString.split('/')
if (dates.length !== 2) {
return dateString
}
const month = Number(dates[0])
const date = Number(dates[1])
const today = new Date()
const currentMonth = today.getMonth() + 1
const currentDate = today.getDate()
let targetYear = today.getFullYear()

if (currentMonth <= month && currentDate <= date) {
targetYear = -1
}

return `${targetYear}/${month}/${date}`
}
Copy link
Contributor Author

@biga816 biga816 May 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

日付が3/10と言った形式だとDateオブジェクト取得する際に年が不明になってまい閏年などで日付がずれてしまう可能性があるため、以下のロジックで年を補完する処理を作成した。

  • 年を含まないデータは1年以上データを保持しない。
  • 1年以上保持しないのであれば、現在より古い日付のデータは去年のデータと推測できる。
  • 最新のデータは翌日以降に取得するので、現在と同じ日付のデータも去年のものと考えられる。
  • 一部だけ年を含むデータが入ってくることを考慮し、/によりsplitした結果が�長さ2の配列にならない場合はそのままデータを返すようにした。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます。
ファイル名なのですが formatDate.ts があるのでそちらに統合する形がいいかなと思います。
また、こちらの処理について、この関数を使うか元データの方で年部分まで保持する形にするか、一度検討してみたいと思います。

Copy link
Contributor Author

@biga816 biga816 May 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaySoMusician formatDate.ts に統合しました!

@biga816 biga816 marked this pull request as ready for review May 17, 2020 17:23
@y-chan
Copy link
Contributor

y-chan commented May 17, 2020

外部の人間ですが一応指摘を...

TimeBarChartを使っているグラフにおいてのみ、Y軸の目盛りがズレ、X軸の日付が消えます。英語の場合は月の部分も消えています。こちらを修正しなければならないと思います。

参考画像(画像はAndroid 9 / Google Chromeですが、Windows 10 / Google Chromeでも発生することを確認済みです。)
IMG_f5yhl8
IMG_-sy3fgn

@y-chan
Copy link
Contributor

y-chan commented May 18, 2020

また、都営地下鉄の利用者数の推移のグラフにカーソルを合わせても、ツールチップが表示されず、エラーを吐いていることを確認しています。
image

@biga816
Copy link
Contributor Author

biga816 commented May 20, 2020

@y-chan ご確認いただきありがとうございます!
@y-chan @MaySoMusician 諸々修正しましたー
合わせて、一部tooltipにて修正漏れがあったので合わせて対応しまいた。

y-chan
y-chan previously approved these changes May 20, 2020
Copy link
Contributor

@y-chan y-chan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMです。

@biga816
Copy link
Contributor Author

biga816 commented May 31, 2020

@MaySoMusician コンフリクトしていたようなので修正しておきました。
ご確認よろしくお願いします。

Copy link
Contributor

@MaySoMusician MaySoMusician left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

対応ありがとうございます!
最近追加された「モニタリング指標」関連については別途issueを立てる形にしようかなと思います

@MaySoMusician MaySoMusician added i18n 多言語関連の Issue や Pull Request ready-for-merge コードレビューが終わり、マージができるもの labels May 31, 2020
@biga816
Copy link
Contributor Author

biga816 commented May 31, 2020

@MaySoMusician かしこまりました!
アサインしていただければまた対応可能です。
よろしくお願いします。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i18n 多言語関連の Issue や Pull Request ready-for-merge コードレビューが終わり、マージができるもの
Projects
None yet
4 participants