Number translation

matt

Member
Oct 30, 2017
40
1
8
49
today I updated to the latest freeswitch version. since then the number translation doesn´t work anymore:

2026-05-26 14:56:49.877126 96.67% [DEBUG] mod_pgsql.c:829 Query (select * from v_number_translations order by number_translation_name asc number_translation_enabled = true ) returned PGRES_FATAL_ERROR
2026-05-26 14:56:49.877126 96.67% [ERR] switch_core_sqldb.c:1300 ERR: [select * from v_number_translations order by number_translation_name asc number_translation_enabled = true ]
[FEHLER: Syntaxfehler bei »number_translation_enabled«
LINE 1: ...translations order by number_translation_name asc number_tra...
^
]
2026-05-26 14:56:49.877126 96.67% [ERR] switch_core_sqldb.c:1300 ERR: [select * from v_number_translations order by number_translation_name asc number_translation_enabled = true ]
[FEHLER: Syntaxfehler bei »number_translation_enabled«
LINE 1: ...translations order by number_translation_name asc number_tra...
^
]
 
**[FIX] Number Translation broken after FreeSwitch update – PGRES_FATAL_ERROR / SQL syntax error**

After updating FreeSwitch, number translations stop working with the following error in the log:

```
[DEBUG] mod_pgsql.c:829 Query (select * from v_number_translations order by number_translation_name asc number_translation_enabled = true ) returned PGRES_FATAL_ERROR
[ERR] switch_core_sqldb.c:1300 ERR: [...]
ERROR: syntax error at or near "number_translation_enabled"
```

**Root cause:**
The file `translate.conf.lua` contains a broken SQL query — the `WHERE` keyword is missing and the `ORDER BY` clause is in the wrong position:

```lua
-- BROKEN (current):
sql = "select * from v_number_translations "
sql = sql .. "order by number_translation_name asc "
sql = sql .. "number_translation_enabled = true "
```

**Fix:**

The affected file is:
```
/usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua
```

Step 1 – Backup the file:
```bash
cp /usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua \
/usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua.bak
```

Step 2 – Apply the fix:
```bash
sed -i \
's/sql = sql .. "order by number_translation_name asc ";/sql = sql .. "where number_translation_enabled = true ";/' \
/usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua

sed -i \
'/sql = sql .. "number_translation_enabled = true ";/d' \
/usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua

sed -i \
'/sql = sql .. "where number_translation_enabled = true ";/a\ sql = sql .. "order by number_translation_name asc ";' \
/usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua
```

Step 3 – Verify the result:
```bash
grep -A3 "select \* from v_number_translations" \
/usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua
```

Expected output:
```lua
sql = "select * from v_number_translations "
sql = sql .. "where number_translation_enabled = true "
sql = sql .. "order by number_translation_name asc "
```

Step 4 – Clear the cache and reload the module:
```bash
rm -rf /var/cache/fusionpbx/*
fs_cli -x "reload mod_translate"
```

Step 5 – Apply the same fix to the FusionPBX web directory so it survives future updates:
```bash
cp /usr/share/freeswitch/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua \
/var/www/fusionpbx/app/switch/resources/scripts/app/xml_handler/resources/scripts/configuration/translate.conf.lua
```

Tested and confirmed working.