Linux
如何讓這個 conky (Conky Vision) 使用英語以外的其他語言?
我想使用這個 conky 腳本:Conky Vision
但我不希望星期幾以英文顯示。
當我將語言環境更改為另一種語言時,今天的日期以該語言顯示,但圖像下部的 5 天名稱始終為英文,即使我將系統語言更改為不同的語言。
我也更改了系統語言,但那些日子仍然以英語顯示。
我應該對該腳本進行哪些更改以使其遵循我想要的語言?
conkyrc 文件有以下內容:
# Conky settings # background yes update_interval 1 double_buffer yes no_buffers yes # Window specifications # gap_x 0 gap_y 0 alignment middle_middle minimum_size 600 460 maximum_width 600 own_window yes own_window_type normal own_window_transparent yes own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below own_window_argb_visual yes own_window_argb_value 255 #border_margin 0 #border_inner_margin 0 #border_outer_margin 0 # Graphics settings # draw_shades no draw_outline no draw_borders no draw_graph_borders no # Text settings # use_xft yes xftalpha 0 xftfont Raleway:size=10 override_utf8_locale yes imlib_cache_size 0 # Color scheme # default_color FFFFFF color1 FFFFFF TEXT \ #-----WOIED-----# \ \ ${execi 300 curl -s "http://weather.yahooapis.fr/forecastrss?w=615702&u=c" -o ~/.cache/weather.xml}\ \ \ #---Clock+Date---# \ \ ${font Raleway:weight=Light :size=100}${alignc}${time %H}${alignc}:${alignc}${time %M} ${font Raleway:weight=Light:size=32}${voffset -60}${alignc}${time %A %B %d}\ \ \ #---High Temperatures---# \ \ ${font Raleway:size=20}\ ${voffset 76}${goto 40}${execi 300 grep "yweather:condition" ~/.cache/weather.xml | grep -o "temp=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*"}° ${font Raleway:weight=Light:size=14}\ ${voffset -28}${goto 160}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "high=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==2'}°\ ${goto 270}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "high=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==3'}°\ ${goto 380}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "high=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==4'}°\ ${goto 490}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "high=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==5'}°\ \ \ #---Low Temparatures---# \ \ ${font Raleway:weight=Light:size=10}\ ${voffset 48}${goto 210}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "low=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==2'}°\ ${goto 320}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "low=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==3'}°\ ${goto 430}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "low=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==4'}°\ ${goto 540}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "low=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==5'}°\ \ \ #---Name of the day---# \ \ ${font Raleway:weight=Light:size=14}\ ${voffset 30}${goto 60}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "day=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==1' | tr '[a-z]' '[A-Z]'}\ ${goto 170}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "day=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==2' | tr '[a-z]' '[A-Z]'}\ ${goto 280}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "day=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==3' | tr '[a-z]' '[A-Z]'}\ ${goto 390}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "day=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==4' | tr '[a-z]' '[A-Z]'}\ ${goto 500}${execi 300 grep "yweather:forecast" ~/.cache/weather.xml | grep -o "day=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==5' | tr '[a-z]' '[A-Z]'}\ \ \ #---Weather Icons---# \ \ ${execi 300 cp -f ~/.conky-vision-icons/$(grep "yweather:condition" ~/.cache/weather.xml | grep -o "code=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*").png ~/.cache/weather-1.png}${image ~/.cache/weather-1.png -p 61,260 -s 32x32}\ \ ${execi 300 cp -f ~/.conky-vision-icons/$(grep "yweather:forecast" ~/.cache/weather.xml | grep -o "code=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==2').png ~/.cache/weather-2.png}${image ~/.cache/weather-2.png -p 171,260 -s 32x32}\ \ ${execi 300 cp -f ~/.conky-vision-icons/$(grep "yweather:forecast" ~/.cache/weather.xml | grep -o "code=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==3').png ~/.cache/weather-3.png}${image ~/.cache/weather-3.png -p 281,260 -s 32x32}\ \ ${execi 300 cp -f ~/.conky-vision-icons/$(grep "yweather:forecast" ~/.cache/weather.xml | grep -o "code=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==4').png ~/.cache/weather-4.png}${image ~/.cache/weather-4.png -p 391,260 -s 32x32}\ \ ${execi 300 cp -f ~/.conky-vision-icons/$(grep "yweather:forecast" ~/.cache/weather.xml | grep -o "code=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*" | awk 'NR==5').png ~/.cache/weather-5.png}${image ~/.cache/weather-5.png -p 501,260 -s 32x32}${font}${voffset -46}\
它似乎與文件有關
~/.cache/weather.xml
(更多詳細資訊請參見此處)。該文件包含如下行:
<yweather:forecast day="Fri" date="10 Jul 2015" low="14" high="26" text="Mostly Sunny" code="34" /> <yweather:forecast day="Sat" date="11 Jul 2015" low="15" high="27" text="Mostly Sunny" code="34" /> <yweather:forecast day="Sun" date="12 Jul 2015" low="14" high="22" text="Showers" code="11" /> <yweather:forecast day="Mon" date="13 Jul 2015" low="16" high="24" text="Cloudy" code="26" /> <yweather:forecast day="Tue" date="14 Jul 2015" low="12" high="23" text="AM Showers" code="39" />
我猜,正如評論中所指出的,in 下的命令
---Name of the day---#
正在.conkyrc
編寫和更新~/.cache/weather.xml
上面發布的行(包含英文的日期名稱)。但正如我所見,這些命令只與“yweather:forecast”有關,這可能意味著英文的日子是curl
從雅虎天氣 English_US 網站上獲取的,這就是為什麼它們是英文的。但讓我感興趣的是,當我第一次看到這個 conky 時,它是在一個西班牙網站上,那裡全是西班牙文。那個 PPA 似乎不再起作用了。
*我在基本作業系統 Freya(基於 ubuntu 14.04)
我是那個 conky 主題的創造者。:)
xml 文件中提供了日期的名稱,而 yahoo 的 API 僅提供英文。
您可以使用“execi”並執行 date 命令來顯示所有日期,並使用 LANG 變數更改輸出語言。
這是一個例子:
#---Names of days---# \ \ ${font Raleway:weight=Light:size=14}\ ${voffset 30}${goto 60}${execi 300 LANG=es_ES.UTF-8 date +%a | awk '{print toupper($0)}'}\ ${goto 170}${execi 300 LANG=es_ES.UTF-8 date -d +1day +%a | awk '{print toupper($0)}'}\ ${goto 280}${execi 300 LANG=es_ES.UTF-8 date -d +2days +%a | awk '{print toupper($0)}'}\ ${goto 390}${execi 300 LANG=es_ES.UTF-8 date -d +3days +%a | awk '{print toupper($0)}'}\ ${goto 500}${execi 300 LANG=es_ES.UTF-8 date -d +4days +%a | awk '{print toupper($0)}'}\
更新:
以上(以及問題)與此 conky 腳本的舊版本有關。
較新版本的 Conky Visions(需要
conky
1.10 版(此處)並且jq
為了工作,以及不同的字型)可以通過編輯.conkyrc
區域設置行輕鬆設置不同的語言,模板 9:------------------------------------- -- Locale (e.g. "es_ES.UTF-8") -- Leave empty for default ------------------------------------- template9=""