{"id":2398,"date":"2019-11-26T20:03:40","date_gmt":"2019-11-26T20:03:40","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2398"},"modified":"2022-02-17T07:13:49","modified_gmt":"2022-02-17T07:13:49","slug":"tokens-keys-etc","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/wordpress\/langauges\/tokens-keys-etc","title":{"rendered":"Using tokens, keys, etc"},"content":{"rendered":"\n<p>gettext()_ and the equivalent wordpress __() functions will all return the string you call with if there is no translation found.<\/p>\n\n\n\n<p>A common thought is can I use a key \/ token in place of the source text so that my code never needs to change and just the translations get edited.  Well, yes you can but there are some considerations:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>If no translation is found then you will get the key\/token returned.  There is no way round this, although you could create your own function call (or trap the wordpress gettext() ) and perform a default to the base language translation yourself if you wanted to.<\/li><li>If you really want to use a key\/token then just ensure all the languages have a translation evern if it involves copying the base language translation for now.<\/li><li>Remember many languages are really different to English with very different word ordering and string lengths &#8211; having correct translations is really important to stop a site looking wrong for other language users.<\/li><li>Lots and lots of developers will tell you just don&#8217;t do it, translate the base language translation for typo correction or minor edits, but rely on changing the text in code to cause translations to be required so that you don&#8217;t get in a situation of there being bad translations of changed text.  As some put it: &#8220;the gettext() developers know what they are doing &#8211; get over it and do it their way&#8221;!<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>gettext()_ and the equivalent wordpress __() functions will all return the string you call with if there is no translation found. A common thought is can I use a key \/ token in place of the source text so that my code never needs to change and just the translations get edited. Well, yes you [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[201],"tags":[],"class_list":["post-2398","post","type-post","status-publish","format-standard","hentry","category-langauges"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2398"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2398\/revisions"}],"predecessor-version":[{"id":2401,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2398\/revisions\/2401"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}