.mo file support in CodeIgniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31) +--- Thread: .mo file support in CodeIgniter (/showthread.php?tid=79328) |
.mo file support in CodeIgniter - stopz - 05-29-2021 I'm making Composer packages for CodeIgniter and next step is to translate them into few languages using .mo files. Let me explain why .mo is important: * Easier standard to work with across companies. Approach i came up with is: 1. In router allow for CI {locale} definition. 2. In Config/App.php we set defaultLocale to 'en' but fill up supportedLocales with all .mo files that are present. 3. In Language/en/Sample.php whe have something like this: PHP Code: <?php I looked up system/Language/Language.php:134 which is a fallback to English language -when requested one is not found- thus this greeting should get triggered from lang('Sample.GreetingText'); Question/Problem: I can't find if CodeIgniter does set up Environment for .mo files and if not or what-not then does anyone get the picture i'm trying to achieve and have any suggestions of what could i try? RE: .mo file support in CodeIgniter - InsiteFX - 05-29-2021 This would never be put into the framework this is an addon to the application. RE: .mo file support in CodeIgniter - stopz - 05-29-2021 (05-29-2021, 05:15 AM)InsiteFX Wrote: This would never be put into the framework this is an addon to the application. Which has nothing to do with what I was looking for Anyone else has any bright ides? RE: .mo file support in CodeIgniter - stopz - 05-29-2021 Alright i solved my issue. So what helped me alot was https://stackoverflow.com/questions/1949162/how-could-i-parse-gettext-mo-files-in-php4-without-relying-on-setlocale-locales this MoParser class. I have set up a little helper that is linked to service which has a MoParser Factory attached (so to save memory). Here's the helper: PHP Code: if (! function_exists('l')) And this is the .mo file factory which is called by the helper to return translations. PHP Code: <?php Hope these snippets help anyone stuck with including .mo files! RE: .mo file support in CodeIgniter - InsiteFX - 05-29-2021 And like I mentioned above an addon Library. |