swissspidy / wp-php-translation-files

Proof-of-concept plugin that uses plain PHP files for WordPress translations
GNU General Public License v2.0
10 stars 1 forks source link

Use Translation object instead of plain arrays #9

Open szepeviktor opened 1 year ago

szepeviktor commented 1 year ago
return (new Translation())
    ->setRevisonDate('+0000')
    ->setGenerator('WordPress/6.3-alpha-55629')
    ->addSingularMessage('FooBar', 'Bay')
    ->addSingularMessages([
    'Foo' => 'Bar',
    'Bar' => 'Baz',
    ])
    ->addPluralMessages([
    '1 Dragon' => ['1 Dragon', '2 Dragons'],
    ])
;

... then cache its values in the plugin.

From https://github.com/swissspidy/wp-php-translation-files/commit/0a25fc5d61ae6596b4c75294e21f134522e31f4c

swissspidy commented 1 year ago

This will be a great discussion topic 👍

szepeviktor commented 1 year ago

This will be a great discussion topic 👍

Where I run away bravely when it's my turn!

swissspidy commented 1 year ago

Discussion topics (not an exhaustive list):

szepeviktor commented 1 year ago

Performance

Cache its output after the first run.

User/Developer friendliness

Who do you want to be friendly to? A typist of source code or a software developer with engineering qualities? (theoretical question)

szepeviktor commented 1 year ago

(theoretical question)

Not! I wouldn't design something to be arrays just for making it easy for non-experts. So: Pascal software -> 3 500 000 users Viktor software -> 500 users

swissspidy commented 1 year ago

Cache its output after the first run.

Caching would work for either option, and even for the current .mo file loading process. So I kinda want to ignore caching a bit for this discussion :)