How to translate strings in JS

前端 未结 7 1056
心在旅途
心在旅途 2021-02-10 09:52

I have a project which I want to translate into multiple languages for the PHP Part I use Zend Frameworks Zend_Translate with GetText. Now I want to translate the JS part too.

7条回答
  •  心在旅途
    2021-02-10 10:56

    I have a PHP web page that also exists in several languages. I have written my own language class in PHP and when it came to localizing the JavaScript files I just configured the server to execute .js files as PHP too, and I used my PHP class to translate JavaScript strings.

    Something like this:

    alert ( 'Get ( 'MyString' ); ?>' );
    

    I just include a file that initializes the "$l" at the beginning of every JavaScript file. I have no problems with this.

提交回复
热议问题