Urgently and suddenly it was necessary to make a multi-language small PHP project. The first thing that came to mind was to store a separate JSON file for each language and open it using PHP \ JS to read / write (when editing) information. Now I’ve wondered: can anyone, using JavaScript, read this file directly from the page and make changes to it?
1 answer
Usually localization is done at the server level, where the required file is connected during operation and the string is displayed in the language you need. Since the translation of lines used in an application is often static, static files are used. If there is a need, then the database is used for more flexible use of language settings and values. No one can enter any data and change it ON THE SERVER since JavaScript is a client language, and with the help of it it will be possible to process most of the data already on the client’s machine. (I do not consider the sent POST requests through a proxy that can change anything on the server)
|