keycloak-ui icon indicating copy to clipboard operation
keycloak-ui copied to clipboard

Admin console "supported locales" dropdown doesn't show custom added language.

Open drsmile1001 opened this issue 2 years ago • 7 comments

Describe the bug

By following Server Developer Guid, I added "zh-TW" (Traditional Chinese or 正體中文) to my custom theme.

The new language doesn't show up in dropdown menu. 圖片

I add "zh-TW" by directly access realm_supported_locales table in database. 圖片

And it come up in language selector. 圖片 圖片

Version

19.0.1

Expected behavior

Supported locales should show up custom add language.

Actual behavior

No response

How to Reproduce?

I use docker to run keycloak.

keycloak                                  
├─ themes                                 
│  └─ mytheme                             
│     ├─ account                          
│     │  ├─ messages                      
│     │  │  ├─ messages_en.properties     
│     │  │  └─ messages_zh_TW.properties  
│     │  └─ theme.properties              
│     ├─ email                            
│     │  ├─ messages                      
│     │  │  └─ messages_zh_TW.properties  
│     │  └─ theme.properties              
│     └─ login                            
│        ├─ messages                      
│        │  ├─ messages_en.properties     
│        │  └─ messages_zh_TW.properties  
│        └─ theme.properties              
├─ docker-compose.yml                     
└─ dockerfile                             
  • docker-compose.yml binding themes to /opt/keycloak/themes
version: "3.2"

services:
  keycloak:
    container_name: keycloak
    image: keycloak:my
    build: .
    restart: unless-stopped
    volumes:
      - type: bind
        source: ./themes
        target: /opt/keycloak/themes
    entrypoint:
      [
        "/opt/keycloak/bin/kc.sh",
        "start",
        "--spi-theme-static-max-age=-1",
        "--spi-theme-cache-themes=false",
        "--spi-theme-cache-templates=false",
      ]
  • themes/mytheme/account/messages/messages_en.properties
  • themes/mytheme/login/messages/messages_en.properties
# encoding: utf-8
locale_zh-TW=正體中文

Anything else?

I also notice the "zh-CN" (Simplified Chinese or 简体中文) on "supported locales" dropdown shows "中文". Dose't match "中文简体" in origin resources properties.

https://github.com/keycloak/keycloak/blob/main/themes/src/main/resources/theme/base/account/messages/messages_en.properties

\u4e2d\u6587\u7b80\u4f53 is "中文简体"

locale_ca=Catal\u00e0
locale_cs=\u010Ce\u0161tina
locale_de=Deutsch
locale_en=English
locale_es=Espa\u00f1ol
locale_fr=Fran\u00e7ais
locale_hu=Magyar
locale_it=Italiano
locale_ja=\u65e5\u672c\u8a9e
locale_lt=Lietuvi\u0173
locale_nl=Nederlands
locale_no=Norsk
locale_pl=Polski
locale_pt-BR=Portugu\u00eas (Brasil)
locale_ru=\u0420\u0443\u0441\u0441\u043a\u0438\u0439
locale_sk=Sloven\u010dina
locale_sv=Svenska
locale_tr=T\u00FCrk\u00E7e
locale_zh-CN=\u4e2d\u6587\u7b80\u4f53
locale_fi=Suomi

drsmile1001 avatar Aug 19 '22 06:08 drsmile1001

Moving this issue to keycloak-ui repo.

ssilvert avatar Aug 22 '22 18:08 ssilvert

@drsmile1001 Does the language show up if you switch to the old admin console?

To switch:

  1. Go to Realm Settings --> Themes
  2. Change Admin Console theme to keycloak

ssilvert avatar Sep 16 '22 19:09 ssilvert

Yes

圖片

drsmile1001 avatar Sep 19 '22 00:09 drsmile1001

I tried to reproduce this but for me it does show up when I add the locale to the theme.properties locales: image You right we no longer uses the display names in the resource bundle, but instead use the names that the browser uses. So for zh-TW that is 中文(台灣) and for zh-CH it's 中文(中国)

edewit avatar Sep 26 '22 05:09 edewit

Yeah, although the functionality does not match what was there before I'd argue this solution is actually better as it relies on standardized APIs. I vote to close this issue.

@ssilvert @edewit @agagancarczyk WDYT?

jonkoops avatar Oct 04 '22 09:10 jonkoops

I tried to reproduce this but for me it does show up when I add the locale to the theme.properties locales: image You right we no longer uses the display names in the resource bundle, but instead use the names that the browser uses. So for zh-TW that is 中文(台灣) and for zh-CH it's 中文(中国)

I try pull latest docker image. Admin UI versiondd67b3b3a4e80031d32fdf0ffd9e9d450a657d07 It show 中文(中国) on Supported locales but zh-TW not 中文(台灣) But Default locale show 中文(台灣) And zh-TW option will disappear if unselect it.

Switch back to v1 theme. zh-TW will appear.

圖片 圖片 圖片

圖片

drsmile1001 avatar Oct 05 '22 00:10 drsmile1001

PR #3487 fixes this

edewit avatar Oct 06 '22 05:10 edewit