【问题标题】:PostgreSQL dates function output to a french languagePostgreSQL 日期函数输出到法语
【发布时间】:2018-08-07 16:36:38
【问题描述】:

如何将PostgreSQL日期函数的结果以to_char输出为法语,例如:

select to_char(current_date, 'Day') ;

应该是(一天的法语名称):

Mardi 

而不是当天的英语(例如 Monady)

【问题讨论】:

    标签: postgresql postgresql-9.5


    【解决方案1】:

    您需要将日期/时间 (LC_TIME) 的显示设置为法语,并且使用 TM prefix 查询的不是 Day,而是可本地化的日期 TMDay

    show LC_TIME;
    SET LC_TIME = 'French';
    select to_char(current_date, 'TMDay') ;
     to_char
    ---------
     Mardi
    (1 row)
    

    【讨论】:

      【解决方案2】:

      以下适用于 Ubuntu 16.04 服务器,带有英语语言设置

      首先我们需要通过以下命令为法语模板添加系统支持:

      sudo locale-gen fr_FR.utf8
      

      然后重启postgresql服务:

      sudo systemctl restart postgresql
      

      然后登录psql

      SET LC_TIME = 'fr_FR.utf8';
      select to_char(current_date, 'TMDay') ;
      to_char
      ---------
      Mardi
      (1 row)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-09
        • 1970-01-01
        相关资源
        最近更新 更多