![]() |
Language in CI - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Language in CI (/showthread.php?tid=56836) |
Language in CI - El Forum - 01-23-2013 [eluser]xerosis[/eluser] I think the language Class and Helper documentation in CI are not as clear as the other sections for example it says and I quote: "Loading A Language File In order to fetch a line from a particular file you must load the file first. Loading a language file is done with the following code: $this->lang->load('filename', 'language');" What is that file supposed to me? XML? CSV? ... How are items supposed to be placed in that file. Does anyone know where we can see best practice tutorial or examples, none are given in the documentations. Language in CI - El Forum - 01-24-2013 [eluser]Aken[/eluser] There are default language files in the system directory that you can use as reference for creating your own. Language in CI - El Forum - 01-24-2013 [eluser]xerosis[/eluser] Yes. Those are system messages. But I need a quicker way of doing localization of the whole website. For example an excel file that shows all the sentences (on my website) in English and in Arabic. Sentences such as: "World class distribution of items" "Welcome to the offical website of ABC company" ... Non System sentences. All in an excel file that loads and based on language is used. Language in CI - El Forum - 01-24-2013 [eluser]Aken[/eluser] The language library is built to accept config files just like the ones in the system directory. If you want to use CI's out of the box functionality, that's the type of language files you'll need to generate -- PHP files for each language containing a $lang array with key => value assignments. If you want to use another file format to specify your translations, you should either extend and adjust the Language library adding your own functionality, or create your own completely separate library from scratch. Language in CI - El Forum - 01-24-2013 [eluser]xerosis[/eluser] Is there not an easier way rather than having to write something like this for every single item: $lang['db_unable_to_select'] = 'Unable to select the specified database: %s'; There needs to be a way to do it through XML or CSV. Language in CI - El Forum - 01-24-2013 [eluser]PhilTem[/eluser] There's no CI built-in way of doing it with XML or CSV. And what would be the difference? Only the markup language would change, but you would be writing similar lines of code for XML. Just CSV might be faster, but can be a pain in the you-know-where reading it properly if there's just one typo or misplaced comma ![]() By the way: There's copy-paste, so you can copy $lang[''] = ''; and past it into the next line ![]() Language in CI - El Forum - 01-24-2013 [eluser]xerosis[/eluser] "By the way: There’s copy-paste, so you can copy $lang[’‘] = ‘’; and past it into the next line" LOL! How could I forget ![]() Thanks for the help though. Language in CI - El Forum - 01-24-2013 [eluser]Aken[/eluser] [quote author="xerosis" date="1359015899"]Is there not an easier way rather than having to write something like this for every single item: $lang['db_unable_to_select'] = 'Unable to select the specified database: %s'; There needs to be a way to do it through XML or CSV.[/quote] Not using default CI functionality, no. You'll need to write your own code for that. It shouldn't take much work if you just want to pull info from a file and create the $lang array with it. Language in CI - El Forum - 01-25-2013 [eluser]Unknown[/eluser] xerosis, I did not understand what did you do to solve your problem... Did you create your own file, like "mywebsite.php" and added your lines of translate, like $lang['add_new_product'] = "Your product %s was sucessfull added."; Am I right? |