3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DockerのpgAdmin4で初回コンテナ起動時から表示言語を日本語にする

Last updated at Posted at 2022-09-01

2024/4/23 大幅修正

コメントにてPGADMIN_PREFERENCES_JSON_FILEを教えて頂いたため、修正しました。
情報ありがとうございました。

画面からの変更の仕方

dpage/pgadmin4を使用してデスクトップモード(PGADMIN_CONFIG_SERVER_MODE=False)で
コンテナを立ち上げてブラウザでアクセスすると画面の言語が英語になっています。
日本語に変更するには

  1. File -> Preferences -> Miscellaneous -> User language
  2. Japanese を選択 -> Save
  3. Refresh
    をすれば良いのですが面倒くさいです。
    image.png

初回のブラウザアクセスから日本語に出来ないか調査したため、投稿します。

環境

  • image: dpage/pgadmin4:8.5 をデスクトップモード(PGADMIN_CONFIG_SERVER_MODE=False)で使用
  • 試した結果

確認内容

pgadmin4:8.4からの環境変数でPGADMIN_PREFERENCES_JSON_FILEが追加されました。
PGADMIN_PREFERENCES_JSON_FILEを指定することで環境設定を事前に設定することが出来るようになりました。

docker-compose.yml 抜粋
  pgadmin:
    build:
      context: ./pgadmin
    image: pgadmin
    container_name: pgadmin
    ports:
      - 5050:80
    environment:
      - PGADMIN_DEFAULT_EMAIL=pgadmin4@pgadmin.org
      - PGADMIN_DEFAULT_PASSWORD=admin
      - PGADMIN_CONFIG_SERVER_MODE=False
      - PGADMIN_SERVER_JSON_FILE=/pgadmin/servers.json
      - PGADMIN_PREFERENCES_JSON_FILE=/pgadmin/preferences.json           <---- これ
      - PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False
      - PGADMIN_CONFIG_UPGRADE_CHECK_ENABLED=False
      - PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION=False
    volumes:
      - ./pgadmin/storage:/root/storage
      - ./pgadmin/servers.json:/pgadmin/servers.json
      - ./pgadmin/preferences.json:/pgadmin/preferences.json               <---- ここでホストとコンテナ共有
    user: root
    restart: always
    entrypoint: /entrypoint.sh
    depends_on:
      - postgres
preferences.json
{
  "preferences": {
    "misc:user_language:user_language": "ja"
  }
}

jsonの書き方はJSON formatにありました。
key名は環境設定画面でカーソルを合わせると見えるみたいです。

image.png

実施結果

環境はgithubに置いています。
以下のようなイメージです。

image.png

ツリーは↓

├── README.md
├── image.drawio
├── image.png
└── src
    ├── docker-compose.yml
    ├── pgadmin
    │   ├── Dockerfile
    │   ├── pgpass
    │   ├── preferences.json
    │   ├── servers.json
    │   └── storage
    └── postgres
        ├── Dockerfile
        └── initdb
            ├── eventstore.backup
            └── init.sh

起動方法

cd src
docker-compose up -d

pgadminへのアクセスと結果

http://localhost:5050

image.png

終了方法

cd src
docker-compose down --volumes

まとめ

pgadmin:8.4からですが、PGADMIN_PREFERENCES_JSON_FILEのおかげで初期起動から表示言語を日本語に出来るようになりました。

3
2
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?