Jump to content

Overwriting Site Translation Files?


Inxentas
 Share

Recommended Posts

A client of mine wants his translations being done by an external agency. I've showed them the Site Translation Files and they can deliver me the required translations in the same JSON format. I went about it by first making some translation files for each language, so there's an ID and all the fields get an identifier. The intent is to give them the file, they change the content, and we place those files back. 

From there I've done some testing and it appears we could simply change the content of these files, as long as the JSON format is being respected. Whenever I changed something, the translation worked properly. So I sent a JSON file to the translator and had them translate the strings. There's no stuff in there that needs escaping so I figured this should work properly. At first they screwed up the values in the "file" and "textdomain" properties of the JSON object, but we fixed that. However, when I place the file in it's appropriate folder I get the following error:

Fatal error: Uncaught TypeError: Argument 3 passed to ProcessWire\LanguageTranslator::textdomainTemplate() must be of the type array, null given, called in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 485 and defined in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 137

TypeError: Argument 3 passed to ProcessWire\LanguageTranslator::textdomainTemplate() must be of the type array, null given, called in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 485 in C:\wamp\www\bamboobrands.com\public_html\wire\modules\LanguageSupport\LanguageTranslator.php on line 137

When I delete the JSON file the error goes away so I'm quite sure it's the file causing the issue.

I did the following test:

  1. Deleted the language file and remade it via Find Files To Translate.
  2. Copied the file's content into a new JSON file.
  3. Overwritten the language file with this new JSON file.

The same error occurs. I've confirmed with DiffChecker that the files are 100% identical. Somehow this issue only occurs when I overwrite the file. I seem to be able to copy-paste the data in, but using a different file causes above error. What could be causing this? Encoding maybe? I couldn't get the translator's file to work, but I could paste their work into the file. 

(I've told my client translation is an maintenance issue because his content will keep changing anyway. He is adamant that we do it this way, disregarding the fact that pasting in his translations would be less work then working around any coding issues. I know it's kind of stupid and error-prone to do it this way).

Link to comment
Share on other sites

Just a thought: How do you overwrite the files? Do you pass them through the UI mask in admin? If yes, have you set the file field in the system template for translations to be allowed to override existing files on upload? If I remember right, I once had to do that in a similar situation, (but not sure).

Link to comment
Share on other sites

9 hours ago, horst said:

Just a thought: How do you overwrite the files? Do you pass them through the UI mask in admin? If yes, have you set the file field in the system template for translations to be allowed to override existing files on upload? If I remember right, I once had to do that in a similar situation, (but not sure).

No, I simply moved them to a local directory, hoping that would be sufficient. Uploading them via the admin seemed to work, thank you! I'm still curious as to what is the difference (what uploading them via the admin actually does apart from storing the file). I could not find a "translation" system template, did you perhaps mean the language_files_site system Field? That one seems to have an option to allow for overwriting files.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...