Hong-Kong-Districts-Info / hktrafficcollisions

Shiny app dashboard of HK traffic collisions that result in injury. | 香港車禍傷亡資料庫:利用互動地圖和儀表版,將香港車禍位置和相關數據可視化。
Other
8 stars 2 forks source link

Feat: Add live translation for hotzone tab #77

Closed KHwong12 closed 2 years ago

KHwong12 commented 2 years ago

Summary

This branch adds live language translation for hotzone tab.

https://user-images.githubusercontent.com/29334677/188651073-8fa86d29-616a-4cf4-ba61-32834ac34c03.mp4

hotzone-translation-chi

Changes

The changes made in this PR are:

  1. Add two new columns, Name_zh and District_zh in the raw spatial data of hotzone street sections (hotzone_streets.gpkg) and table (hotzone_out_df.fst)
  2. Add live language translation to the interactive hotzone map, including 1. legend name, 2. layer name and 3. popup details.
  3. Add live language translation to the details of interactive table (datatable), including column names and attributes.
  4. Add live language translation to the interactive table (datatable) UI.

Check


Note

The current approach for live translation that cannot be done by simply using i18n$t() (#73) is to wrap variables into a if(input$selected_language == "en") {} else {} control flow.

if(input$selected_language == "en") {TABLE_COLUMN_NAMES_EN} else {TABLE_COLUMN_NAMES_ZH}