We have quite a large Craft based site that requires load balancing so there are often multiple instances of the site.

The problem we are having is with the translation files. Because these are stored as files when you update them through the admin they are only updated on the site instance you are currently on. Obviously this isn't scalable.

What would be the best solution to make these static translations scalable in this sort of environment? Move the translation files to an S3 bucket? (this would be ideal but have don't think this is possible) or move all translation fields to the database somehow? (what would be the best field type to store them as and where?) or is there some other solution?

  • Are you referring to Craft's static translation support? I think so, but you mention updating them through the admin and now I'm not sure.
    – Brad Bell
    Sep 27 '15 at 19:37
  • Yes I am referring to the static translation support... and sorry forgot to mention that we're using the "translate" plugin that gives an interface for updating these files through the admin straightupcraft.com/craft-plugins/translate.
    – markstewie
    Sep 27 '15 at 19:41

Why not just check your site into a git or subversion repository, and when the translation files are updated, push them to the repo, and have the other servers pull the changes down?

You could even automate it with the various git hooks.

  • Thanks @khalwat, yeah something like that could work for sure. I think the complication in all of this is using the "translate" plugin... I think we are going to have to stop using it and just do something like this instead.
    – markstewie
    Sep 28 '15 at 3:20

One option would be to set the CRAFT_TRANSLATIONS_PATH PHP constant in your public index.php file and have that point to a network storage path that all web servers can point to.

  • Thanks Brad, yeah thought that could be an option... but it makes it complicated that we're using the translate plugin as that has it's own translations path that stores the translation files inside the plugin folder by default.
    – markstewie
    Sep 27 '15 at 19:45
  • Looks like someone ran into a similar issue already: github.com/boboldehampsink/translate/issues/12
    – Brad Bell
    Sep 27 '15 at 19:49
  • Hmm.. yeah, that is exactly the same issue. Doesn't look like there is an easy solution.
    – markstewie
    Sep 27 '15 at 19:52
  • Ok so if I don't use the translations plugin at all and set the CRAFT_TRANSLATIONS_PATH constant to a s3 translations bucket it works... (after setting allow_url_include to On in my php.ini) but makes every request slow. I'm really not sure what the answer is to this...
    – markstewie
    Sep 27 '15 at 22:33
  • Yeah, that means you're making an S3 request on every Craft request. An NFS network share would be faster.
    – Brad Bell
    Sep 28 '15 at 5:34

Another solution would be to setup a cronjob on your master server to run a rsync on the translation files to the other edge servers every minute / 10 minute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.