![]() ![]() Language files on the server handling the request are updated.Below are the steps I wanted to achieve upon the save button being clicked. I started by building an interface that allowed the administrator to update the content of the language files. This is how I decided to tackle the problem, leveraging Amazon s3 and the fantastic suite of AWS CLI tools in the process. Therefore, a whole lot of work would need to be done to make it possible.Īnother option would be to use a central file store. Perhaps the bigger issue is Laravel does not support a database-driven solution to localisation. Obviously caching would likely be used to help reduce this overhead. However, this could end up in a lot of expensive database queries if having to look up every translation on page load. Usually, it makes sense for this location to be the database. One solution to this issue is to store the translations in a central location that becomes the single point of truth. Again, no popularity contests would be won if that solution were to make it into production. In that scenario, different content would be served between requests. Only the server that happens to win the lottery, so to speak, and serve the request when the user clicked save would have the changes reflected. Moreover, what if the application were deployed to multiple servers? If the server were to fail catastrophically, all of the changes made since the last push would be lost forever and that wouldn’t make us very popular. However, once you get into the realms of exposing an interface that updates the language files in real time, any changes made are no longer tracked in git. In this scenario, the language files get updated, changes are committed and deployed and the changes are live. Laravel’s ‘out-of-the-box solution’ is great in a project that lives in git and where content is provided by the client and updated manually by the developer. However, what happens when the translations need to be updated the on-the-fly? Then, set the user’s locale in configuration and hey presto content is being served in the desired locale. Simply define the translations in either JSON or PHP key => value syntax, and wrap the content in one of the various different localisation helper functions. The app was built using Laravel which, out of the box, provides functionality to make the display of localised content a breeze. ![]()
0 Comments
Leave a Reply. |