{"action":"created","issue":{"url":"https://api.github.com/repos/Elgg/Elgg/issues/9375","repository_url":"https://api.github.com/repos/Elgg/Elgg","labels_url":"https://api.github.com/repos/Elgg/Elgg/issues/9375/labels{/name}","comments_url":"https://api.github.com/repos/Elgg/Elgg/issues/9375/comments","events_url":"https://api.github.com/repos/Elgg/Elgg/issues/9375/events","html_url":"https://github.com/Elgg/Elgg/issues/9375","id":133006241,"number":9375,"title":"correct elgg_language_key_exists() usage is messy","user":{"login":"mrclay","id":170687,"avatar_url":"https://avatars.githubusercontent.com/u/170687?v=3","gravatar_id":"","url":"https://api.github.com/users/mrclay","html_url":"https://github.com/mrclay","followers_url":"https://api.github.com/users/mrclay/followers","following_url":"https://api.github.com/users/mrclay/following{/other_user}","gists_url":"https://api.github.com/users/mrclay/gists{/gist_id}","starred_url":"https://api.github.com/users/mrclay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrclay/subscriptions","organizations_url":"https://api.github.com/users/mrclay/orgs","repos_url":"https://api.github.com/users/mrclay/repos","events_url":"https://api.github.com/users/mrclay/events{/privacy}","received_events_url":"https://api.github.com/users/mrclay/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-02-11T15:37:06Z","updated_at":"2016-02-12T13:32:50Z","closed_at":null,"body":"`elgg_language_key_exists()` doesn't consider that what the developer usually cares about it whether the key will be translated at all. Consider this example:\r\n\r\nA plugin checks a language key \"foo:$type\":\r\n\r\n```php\r\nif (elgg_language_key_exists(\"foo:$type\")) {\r\n```\r\n\r\nNow a Spanish site installs it, defines that key in \"es\". This will fail because the plugin's check only checks for the English translations. OK, so the plugin is rewritten:\r\n\r\n```php\r\nif (elgg_language_key_exists(\"foo:$type\", get_language())) {\r\n```\r\n\r\nNow it's installed on an English site and the key is defined under \"en\". This will fail for a user who's language is set to \"es\". So really a dev has to do check both:\r\n\r\n```php\r\nif (elgg_language_key_exists(\"foo:$type\", get_language()) || elgg_language_key_exists(\"foo:$type\")) {\r\n```\r\n\r\nI think we'd really want a function that would check the fallbacks as well, maybe `elgg_can_echo()`?"},"comment":{"url":"https://api.github.com/repos/Elgg/Elgg/issues/comments/183330713","html_url":"https://github.com/Elgg/Elgg/issues/9375#issuecomment-183330713","issue_url":"https://api.github.com/repos/Elgg/Elgg/issues/9375","id":183330713,"user":{"login":"jdalsem","id":861833,"avatar_url":"https://avatars.githubusercontent.com/u/861833?v=3","gravatar_id":"","url":"https://api.github.com/users/jdalsem","html_url":"https://github.com/jdalsem","followers_url":"https://api.github.com/users/jdalsem/followers","following_url":"https://api.github.com/users/jdalsem/following{/other_user}","gists_url":"https://api.github.com/users/jdalsem/gists{/gist_id}","starred_url":"https://api.github.com/users/jdalsem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdalsem/subscriptions","organizations_url":"https://api.github.com/users/jdalsem/orgs","repos_url":"https://api.github.com/users/jdalsem/repos","events_url":"https://api.github.com/users/jdalsem/events{/privacy}","received_events_url":"https://api.github.com/users/jdalsem/received_events","type":"User","site_admin":false},"created_at":"2016-02-12T13:32:50Z","updated_at":"2016-02-12T13:32:50Z","body":"It think the amount of cache updates is not that frequent.. we can cache based on the unique combination of languages `md5('en-nl-fr')`.. there are not that many unique combinations on an average site..."}}