{"id":6742,"date":"2023-11-01T01:18:00","date_gmt":"2023-11-01T01:18:00","guid":{"rendered":"https:\/\/musilda.cz\/?p=6742"},"modified":"2023-11-01T01:18:00","modified_gmt":"2023-11-01T01:18:00","slug":"zrychleni-nacitani-webu-s-pluginem-performant-translations","status":"publish","type":"post","link":"https:\/\/affinite.io\/cs\/zrychleni-nacitani-webu-s-pluginem-performant-translations\/","title":{"rendered":"Zrychlen\u00ed na\u010d\u00edt\u00e1n\u00ed webu s pluginem Performant Translations"},"content":{"rendered":"\n
Rychlost WordPressu je t\u00e9matem, ke kter\u00e9mu se t\u00fdmy kolem j\u00e1dra, chovaly dost dlouho mace\u0161sky. V\u0161e co se dalo re\u00e1ln\u011b d\u011blat, je vyu\u017e\u00edt n\u011bkter\u00fd z cache plugin\u016f, nebo optimalizovat obr\u00e1zky.<\/p>\n\n\n\n
Jsem proto r\u00e1d, \u017ee se posledn\u00ed dobou za\u010daly objevovat snahy, vylep\u0161it i v\u011bci, kter\u00e9 se t\u00fdkaj\u00ed p\u0159\u00edmo j\u00e1dra. <\/p>\n\n\n\n
A jednou z nich je na\u010d\u00edt\u00e1n\u00ed p\u0159eklad\u016f<\/strong>. <\/p>\n\n\n\n Pokud pou\u017e\u00edv\u00e1te WordPress v jin\u00e9m jazyce, ne\u017e je angli\u010dtina (co\u017e jsme asi v\u0161ichni), tak jste se setkali s Loco Translate<\/strong>, nebo programem PoEdit<\/strong>.<\/p>\n\n\n\n Ty vyu\u017e\u00edvaj\u00ed pro lokalizaci \u0161ablon a plugin PO a MO soubory. <\/p>\n\n\n\n Co\u017e znamen\u00e1, \u017ee p\u0159i na\u010dten\u00ed ka\u017ed\u00e9 str\u00e1nky ve WordPressu, je t\u0159eba na\u010d\u00edst a parsovat v\u0161echny <\/strong>MO soubory. <\/p>\n\n\n\n A to je proces, n\u00e1kladn\u00fd na zdroje.<\/strong><\/p>\n\n\n\n WordPress m\u00e1 vlastn\u00ed MO parser, proto\u017ee gettext<\/a> roz\u0161\u00ed\u0159en\u00ed pro PHP, nemus\u00ed b\u00fdt na serveru nainstalovan\u00e9. <\/p>\n\n\n\n P\u0159i hled\u00e1n\u00ed a testov\u00e1n\u00ed alternativn\u00edch \u0159e\u0161en\u00ed se vyno\u0159il i plugin, kter\u00fd pou\u017e\u00edv\u00e1 nativn\u00ed gettext roz\u0161\u00ed\u0159en\u00ed, pokud je na serveru – Native gettext<\/a>.<\/p>\n\n\n\n Instalace a pou\u017eit\u00ed tohoto pluginu je ale z\u00e1visl\u00e1 na implementaci roz\u0161\u00ed\u0159en\u00ed a b\u011b\u017en\u00fd u\u017eivatel nebude v\u011bd\u011bt, jak m\u00e1 postupovat. <\/p>\n\n\n\n A t\u00edm se nakonec dost\u00e1v\u00e1me k tomuto pluginu. <\/p>\n\n\n\n Z pohledu PHP, nen\u00ed nic rychlej\u0161\u00edho, ne\u017e na\u010dten\u00ed jin\u00e9ho PHP souboru. <\/p>\n\n\n\n Performant translations vezme mo, nebo json soubory, v kter\u00fdch jsou ulo\u017een\u00e9 \u0159et\u011bzce, p\u0159evede je na php soubory a ty pak vyu\u017e\u00edv\u00e1. <\/p>\n\n\n\n Zrychlen\u00ed na\u010d\u00edt\u00e1n\u00ed je v \u0159\u00e1dech des\u00edtek milisekund. <\/p>\n\n\n\n P\u0159istupujte k tomu tak, \u017ee ten plugin je sp\u00ed\u0161 pomocn\u00edk a pokud pou\u017eijete \u0161ablonu, kter\u00e1 na\u010d\u00edt\u00e1 2 MB javascriptov\u00fdch soubor\u016f na ka\u017ed\u00e9 str\u00e1nce, m\u011bli by jste \u0159e\u0161it nejd\u0159\u00edve tento probl\u00e9m, ne\u017e rychlost na\u010d\u00edt\u00e1n\u00ed p\u0159eklad\u016f. <\/p>\n\n\n\n Pou\u017eit\u00ed pluginu m\u00e1 ale dv\u011b v\u00fdhody:<\/p>\n\n\n\n D\u00edky tomu, \u017ee zde nen\u00ed \u017e\u00e1dn\u00e9 nastaven\u00ed, m\u016f\u017ee se plugin st\u00e1t b\u011b\u017enou sou\u010d\u00e1st\u00ed instalace WordPress webu. Nav\u00edc po sob\u011b plugin ukl\u00edz\u00ed, tak\u017ee po deaktivaci a odinstalovan\u00ed, jsou soubory smaz\u00e1ny. <\/p>\n\n\n\n Pro mne je p\u0159\u00edjemn\u00e9 p\u0159ekvapen\u00ed, \u017ee po dob\u011b, kdy se sp\u00ed\u0161e \u0159e\u0161il Gutenberg, za\u010d\u00edn\u00e1 se kone\u010dn\u011b koukat i na probl\u00e9my, kter\u00e9 WordPress m\u00e1 a tento plugin jsem ji\u017e za\u010dal pou\u017e\u00edvat na n\u011bkolik webech. Nezaznamenal jsem zat\u00edm \u017e\u00e1dn\u00e9 probl\u00e9my.<\/p>\n\n\n\nPerformant translations<\/h2>\n\n\n\n
Jak moc je to rychlej\u0161\u00ed? <\/h2>\n\n\n\n
<\/a><\/figure>\n\n\n\n
\n
Z\u00e1v\u011br<\/h2>\n\n\n\n