Rail - Can not add translations with special chars

Infos:

  • Used Zammad version: 3.2.0-1580110414.992e734c.centos7
  • Used Zammad installation source: yum
  • Operating system: centos7
  • Browser + version: Firefox 68.4.2esr / Chrome 79.0.3945.130

Expected behavior:

Add a new translation with special chars (e.q. äöüÄÖÜß) for attribute (source: https://docs.zammad.org/en/latest/admin/console/other-usefull-commands.html#add-translation) via rail command without error.

Actual behavior:

Ruby throws an invalid multibyte char (US-ASCII) error. No translation created.

Steps to reproduce the behavior:

###@### ~ # zammad run rails c
Loading production environment (Rails 5.2.4.1)
irb(main):001:0> Translation.create_if_not_exists( :locale => 'en-us', :source => "Aufzüge", :target => "Lifts", format: 'string', created_by_id: 1, updated_by_id: 1 )
Traceback (most recent call last):
SyntaxError ((irb):1: invalid multibyte char (US-ASCII))
(irb):1: invalid multibyte char (US-ASCII)

I also tried it the other way with
Translation.create_if_not_exists( :locale => 'de-de', :source => "Lifts", :target => "Aufzüge", format: 'string', created_by_id: 1, updated_by_id: 1 )
still not working.

Background

I want to translate the attributes of a tree select from german to english.
I tried the same for ‘Sonnenschutz’ with the translation ‘Sun protection’. This worked without any error.

Does anyone has the same error or know how to solve this?

You’re doing it the wrong direction.
As english is the default language in Zammad, you might want to provide english display names on your objects and then translated them to german.

You cannot add translations to english.

Thank you for the reply and the information about the direction of translation, i will keep this in mind.

But still, the error occurs by using special chars like äöüÄÖÜ

As I wrote in my first post, I also tried it the other ‘right’ way (now with full output):

irb(main):008:0> Translation.create_if_not_exists( :locale => 'de-de', :source => "Lifts", :target => "Aufzüge", format: 'string', created_by_id: 1, updated_by_id: 1 )
Traceback (most recent call last):
SyntaxError ((irb):8: invalid multibyte char (US-ASCII))
(irb):8: invalid multibyte char (US-ASCII)

The same formate as shown in your documentation example

Still the same error message: SyntaxError ((irb):1: invalid multibyte char (US-ASCII))

I can successfully create translation without special chars (even in the wrong direction), e.q.:

irb(main):004:0> Translation.create_if_not_exists( :locale => 'en-us', :source => "Sonnenschutz", :target => "Sun protection", format: 'string', created_by_id: 1, updated_by_id: 1 )
=> #<Translation id: 58343, locale: "en-us", source: "Sonnenschutz", target: "Sun protection", target_initial: "Sun protection", format: "string", updated_by_id: 1, created_by_id: 1, created_at: "2020-01-30 11:22:53", updated_at: "2020-01-30 11:22:53">

Please provide the output of locale

As requested:

###@### ~ # localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: de
      X11 Layout: de
###@### ~ # locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=C.UTF-8
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=

Very odd, maybe your databases encoding is off? Because “it works on my machine” ™

root@zammad:~# cat /etc/default/locale
#  File generated by update-locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"
root@zammad:~# locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
root@zammad:~# localectl status
   System Locale: LANG=en_US.UTF-8
                  LANGUAGE=en_US:en
       VC Keymap: n/a
      X11 Layout: de
       X11 Model: pc105
root@zammad:~# zammad run rails c
Loading production environment (Rails 5.2.3)
irb(main):001:0> Translation.create_if_not_exists( :locale => 'en-us', :source => "Aufzüge", :target => "Lifts", format: 'string', created_by_id: 1, updated_by_id: 1 )
=> #<Translation id: 56687, locale: "en-us", source: "Aufzüge", target: "Lifts", target_initial: "Lifts", format: "string", updated_by_id: 1, created_by_id: 1, created_at: "2020-02-04 16:30:50", updated_at: "2020-02-04 16:30:50">
irb(main):002:0>

Please run the following commands and provide their outputs:

root@zammad:~# cd /
root@zammad:/# su postgres -
postgres@zammad:/$ psql
postgres=# SHOW SERVER_ENCODING;
postgres=# SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = 'zammad';

Thanks for your configuration, I found the error.

Reason

Missing locales

###@### ~ # locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=C.UTF-8
[...]

Solution (working for me)

Insert following in the /etc/environment file and reboot:

LC_ALL="en_US.UTF-8"
LANG="en_US.UTF-8"
1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.