Wiki: Error applying locales with country specification

Created on 16 Jul 2019  路  4Comments  路  Source: Requarks/wiki

Describe the bug
Using PostreSQL database, the "locales"."code" column is generated with lenth 2, but some locales are greater (e.g. pt-br). This causes error when downloading and storing translation. I changed the column's length on database, and I was able to download, but when applying the locale, the following error occurs in the frontend:

Error: GraphQL error: Invalid locale or namespace
    at new n (app.265ad7c3872cfbfd74b6.js:2)
    at app.265ad7c3872cfbfd74b6.js:2
    at app.265ad7c3872cfbfd74b6.js:2
    at Set.forEach (<anonymous>)
    at app.265ad7c3872cfbfd74b6.js:2
    at Map.forEach (<anonymous>)
    at e.broadcastQueries (app.265ad7c3872cfbfd74b6.js:2)
    at app.265ad7c3872cfbfd74b6.js:2
    at Object.next (app.265ad7c3872cfbfd74b6.js:1468)
    at _ (app.265ad7c3872cfbfd74b6.js:1468)

To Reproduce
Steps to reproduce the behavior:

  1. On the Admin area, go to "Locale"
  2. Download any locale with country specification, like _pt-br_
  3. Click on "Apply" on top-right corner
  4. See error

Expected behavior
Should works.

Host Info:
image

Edit:
Errors also occurs when creating pages for these locations, because columns like "pages"."localeCode", "pageHistory"."localeCode" are in wrong size.

Most helpful comment

I still have this bug

All 4 comments

Fixed by 08fd10603f7fdfdbe98bffe37e92630f11db2f91

Good catch, this was a big oversight on my part.

Unfortunately, this will require a re-install in order to use these locales as the code is a primary key and cannot be altered by a standard migration (at least not without creating a bunch of temporary tables and moving stuff around).

@NGPixel thanks for the quick answer.

What about the GraphQL error in frontend?

I still have this bug

Hi folks,

I founded the frontend error, when GraphQL request translate bundle from backend is sended "pt-BR", but in database language code is saved as "pt-br", so when the backend try to find translation it cause an Exception, see images below.

File: server/core/localization.js

async getByNamespace(locale, namespace) {
    if (this.engine.hasResourceBundle(locale, namespace)) {
      let data = this.engine.getResourceBundle(locale, namespace)
      return _.map(dotize.convert(data), (value, key) => {
        return {
          key,
          value
        }
      })
    } else {
      throw new Error('Invalid locale or namespace')
    }
  }

Database line

image

Frontend Locale Request

Capturar

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ccolella-mdc picture ccolella-mdc  路  3Comments

D3mon86 picture D3mon86  路  4Comments

SharkProgramming picture SharkProgramming  路  4Comments

ccolella-mdc picture ccolella-mdc  路  3Comments

touhoku-japan picture touhoku-japan  路  3Comments