How to generate translation file (.po, .xliff, .yml,…) from a Symfony2/Silex project?

前端 未结 3 1448
野性不改
野性不改 2021-02-09 15:56

Im going to build a Silex/Symfony2 project and I have been looking around for a method to generate XLIFF/PO/YAML translation files based on texts-to-be-translated inside the pro

3条回答
  •  长发绾君心
    2021-02-09 16:16

    I see you've found a converter, but to answer your first question about generating your initial translation file -

    If you have Gettext installed on your system you could generate a PO file from your "texts-to-be-translated inside the project". The command line program xgettext will scan the source files looking for whatever function you're using.

    Example:
    To scan PHP files for instances of the trans method call as shown here you could use the following command -

    find . -name "*.php" | xargs xgettext --language=PHP --keyword=trans --output=messages.pot
    

    To your question about editors:
    You could use any PO editor, such as POEdit, to manage your translations, but as you say you eventually need to convert the PO file to either an XLIFF or YAML language pack for Symfony.

    I see you've already found a converter tool. You may also like to try the one I wrote for Loco. It supports PO to YAML, and PO to XLIFF

提交回复
热议问题