Structuring Website Translation files

前端 未结 3 1687
鱼传尺愫
鱼传尺愫 2021-02-08 14:41

I faced this problem several times while building websites. I will explain the using PHP and Laravel as an example but this problem is a common amoung multiple platforms. This w

3条回答
  •  旧巷少年郎
    2021-02-08 15:24

    I tend to group functionality in my Laravel apps into self-contained ‘components’. For example, I’ve been working on email campaign functionality for an application recently so put the service provider class, models, service classes in a folder at app/Email.

    Bearing this in mind, I organise my translations in a similar fashion. So even though on this project we’re not translating strings, if we were I would create a resources/assets/lang/en/email.php file, and put translated strings for the email component in there.

    So in another project, my directory structure might look like this:

    • /resources
      • /lang
        • /en
          • auth.php
          • email.php
          • events.php
          • news.php
          • pagination.php
          • passwords.php
          • validation.php

    Hope this helps.

提交回复
热议问题