tolgee-platform icon indicating copy to clipboard operation
tolgee-platform copied to clipboard

Import translations fails when namespace contains a dot

Open kalimantos opened this issue 1 year ago • 7 comments

Running the push cli command, trying to push translations with namespaces containing a dot . the "Applying changes..." step fails returning this error message: "Some of the imported languages weren't recognized. Please create a language with corresponding tag in the Tolgee Platform". After some debugging i noticed that the "/v2/projects/{projectId}/import/apply" request fails returning a statusCode 400 and this response: { code: 'existing_language_not_selected', params: null }.

The folder structure i'm trying to push is: (i'm trying to have user-specific translations using the fallbackNs param set to "common")

I've tried to create the namespaces and some translations on the platform and the pull cli command works perfectly.

Thanks

kalimantos avatar Sep 12 '23 09:09 kalimantos

Hey! Interesting issue! 🚀

Do you have languages with tags en and it created in the platform?

JanCizmar avatar Sep 12 '23 10:09 JanCizmar

Can you maybe share the data you're trying to import, so I can test it locally?

JanCizmar avatar Sep 12 '23 10:09 JanCizmar

Hey! Thanks for the super quick response! I'm not actually using any tags in the platform, here you can find the test data translations.zip

kalimantos avatar Sep 12 '23 10:09 kalimantos

I'm not actually using any tags in the platform, here you can find the test data

This is what we call language tag: https://en.wikipedia.org/wiki/IETF_language_tag

JanCizmar avatar Sep 12 '23 10:09 JanCizmar

sorry 😅 i thought you were talking about tolgee tags Screenshot 2023-09-12 at 12 27 43 yes, i have already set up the project with this 2 languages Screenshot 2023-09-12 at 12 29 53

kalimantos avatar Sep 12 '23 10:09 kalimantos

Oh, I see; it really doesn't automatically pair the languages for some files.

What you can do as a workaround is manually assign the existing languages to the import languages.

Think of import language as a storage for all the translations imported from a single file/namespace in a single language. Tolgee creates this storage when you upload a new file, so you can modify the target existing language later.

You can use these endpoints to set the language manually:

First, you have to get the import result: https://tolgee.io/api#tag/Import/operation/getImportResult_1

The result tells you whether the import language was paired with the existing one. If not, existingLanguageId is null. In that case, you need to get the id of the desired existing language (by calling) https://tolgee.io/api#tag/Languages/operation/getAll_8 In the response, you'll find a language ID you want to select for the import language, so you can call this one https://tolgee.io/api#tag/Import/operation/selectExistingLanguage_1 to pair the import language to the existing language.

The links take you to the docs. They're not the actual endpoint URLs.

JanCizmar avatar Sep 12 '23 10:09 JanCizmar

Thanks

kalimantos avatar Sep 12 '23 10:09 kalimantos