How do you use the Gettext library with Codeigniter for i18n? - codeigniter

I’m finally developing my first multilingual site which came from an old no-CI site which used Gettext cause there’s a lot of text and not just actions. I’m really struggling to make the gettext library to work with CI, having read the WIKI (first option) but I lacks information and examples.
Is there someone here who has used
the gettext library succesfully?
Can you post some examples of controller
and views?
Thanks in advance!

I'd recommend NOT using CI's language libraries for this. Use Poedit or another gettext()/ngettext() replacement program.
Trust me--you'll want all your externalized strings in a compiled format. Doing this from scratch is far more work than it's worth.

Related

Elixir Phoenix inlining css for sending emails

I am sending emails using the mailgun library in Phoenix.
Turns out that when i look at the email in my gmail account, it has been stripped off of all the css classes and the link to external css files.
Mailgun suggests using a css inline library http://blog.mailgun.com/transactional-html-email-templates/
Tried search a lot, but could not find a css inline library for Phoenix/Elixir like the premailer gem in Ruby.
Does anyone know of a way to achieve this?
I just released Smoothie, an Elixir library that does just this. We use this in our product at the startup I run, and decided to write our own library as we also couldn't find one in the elixir ecosystem yet. Check out the github page for installation instructions. Let me know if it works for you!
There is also a library now called premailex which was released October 2017. It handles CSS inlining
I have not been able to find anything myself but I believe you can find tools for that online and use them, it's not exactly the same but I guess it's better than to inline everything manually. For instance, you could use this one. I have not tested it though.
Also you can create a package yourself and share it with us :)

Codeigniter template library build or download?

i am pretty new to CI. been looking at few template libraries but found either they have much more than I need or not enough.
so i started to build my own. is there anything i should keep in mind? in terms of security? caching? etc etc
thank you
A template library is pretty simple to create and unless you have a need for all the stuff that one of the many available have I would just roll your own. With that said I tend to use the one by Phil the most as it matches the closest with the way I do things.

Extend RedCloth via Redmine plugin?

I'm new to Ruby/Redmine/Redcloth but I'm trying to achieve the following:
The default way to build a link in Textile is "foo":http://bar. However, 90% of the day I use Atlassian products, which use [foo|http://bar] as link markup.
To keep everything a bit uniform I'd like to implement this in Redmine via a plugin. However, it appears that you can't change the macro syntax so instead I'll have to look into extending RedCloth to accept this form of inserting links.
Does anyone know how I can achieve this?
Thank you and merry christmas,
Dennis
You might consider switching to one of the two Markdown plugins (one is Markdown Extra-like, based on Bluefeather), which are a bit more similar in link style, although not the same as what you are used to. Since you use SO, though, you're obviously familiar with it.
Otherwise you'd have to write a full plugin, for which either of the plugins I've mentioned would serve as a good model. Best of luck.

Code Highlighting for Joomla

I need syntax highlighting of source code from various languages (PHP, C#, VB, etc) within articles I have in Joomla. I have tried enabling the Geshi plugin, updating the language files and putting the code into my Joomla article - however I can't seem to get it to work.
I have also tried CodeCitation from JED but again, the problem seems to be the same - I don't know how to tell Joomla to process it as code. I placed {codecitation} and {/codecitation} around my code (as well as including the brush value) but it doesn't work. I am unsure if these tags should be placed on the source or the wysiwug
Could someone please assist with an alternative method or work out what I am doing wrong?
With CodeCitation: if you already wrote the article using the tags (i.e. {codecitation} code {/codecitation}), it should work. Did you check if you enable the mambot?
As of Joomla 3.4 Geshi has been removed - but you can still get Geshi+ (geshi repackaged with all the additional languages) - & see the tips here on how to configure geshi.
An example of Geshi+ working is here.
There are now Joomla plugins using highlightjs & google's prettify library to highlight syntax but I found geshi+ worked much better
I am not certain if you can use it in Joomla or not. I use the syntax highlighter by Alex Gorbatchev. I have used it in a couple of blogs (wordpress for instance) and in some stand alone web pages. Not hard to intergrate. It uses the 'pre' tags. You need to be sure the code is already escaped. It may be worth a look. Here is a link.
http://alexgorbatchev.com/SyntaxHighlighter/
Hope this helps.
Bob

Smarty integration into the CodeIgniter framework

A Little Background Information:
I've been looking at a few PHP framework recently, and it came down to two. The Zend Framework or CodeIgniter.
I prefer CodeIgniter, because of its simple design. It's very bare bone, and it is just kept simple. The thing I don't like though is the weak template system. The template system is important for me, because I will be working with another designer. Being able to give him a good template system is a big plus.
Zend was the second choice, because of the better template system that is built in. Zend is a different beast though compared to CodeIgniter. It emphasis "loose coupling between modules", but is a bigger framework. I don't like to feel like I have many things running under the hood that I never use. That is unnecessary overhead in my opinion, so I thought about putting a template system into CodeIgniter: Smarty.
Question(s): How easy/hard is the process to integrate Smarty into CodeIgniter? From my initial scan of the CodeIgniter documentation, I can see that the layout of the framework is easy enough to understand, and I anticipate no problems. I want to know if anyone has used it before, and therefore are aware of any "gotchas" you my have experienced that is going to make this harder than it should be or impossible to pull off. I also want to know if this is a good thing to do at all. Is the template system in CodeIgniter enough for normal use? Are there any other template modules that are good for CodeIgniter aside from Smarty? I better off with Zend Framework? Is any wheel being invented here?
Sorry to resurrect an old question - but none of the answers have been flagged as "accepted" yet.
There's a library called "template" that does a great job of allowing you to use just about any template parser you want:
Template CI Library - V1.4.1
The syntax is pretty easy for integrating into your CI application and the smarty integration spot on.
Slightly OT, hope you don't mind...
I'm a Zend Framework user and I think it's worth saying that the loose coupling means you don't need to include any files you're not actively using. Hopefully this negates your concern about unnecessary overhead.
With the layouts stuff added in a recent release of ZF, its templating is really hard to fault... and it's completely pluggable as Favio mentions. The more I use ZF, the more I like it; they do things the way I would do them!
I did a quick google search and found the following:
http://devcha.blogspot.com/2007/12/smarty-as-template-engine-in-code.html
http://codeigniter.com/forums/viewthread/67127/
If the designer is not familiar with Smarty, I think it's almost the same as if you use the existing CodeIgniter templating system (which leaves everything to PHP actually). It also depends on the complexity of the project at hand.
You can also hook Smarty with Zend Framework. It's more complex than with CodeIgniter, but there's already a primer on how to do exactly that in the ZF documentation. http://framework.zend.com/manual/en/zend.view.scripts.html Plus lots of tutorials on the net.
In my opinion it's almost the same, you can use pure PHP or Smarty as your template "engine", so it depends on the project. Also, compare a developer who has extensive experience and already has a library of view helpers so she uses pure PHP, versus a designer who doesn't know anything about PHP, but has extensive experience with Smarty. Sometimes decisions have to be based on who is going to do what.
Check out this custom CodeIgniter templating library. I've already used it on several projects and it is easy to use. I know this post is late but it's worth checking out.
It doesn't appear there has been an answer selected for this question nor has an up-to-date solution been given to work with the latest version of Codeigniter (2.0) and the latest version of Smarty (3.0.5).
This library allows you to use Smarty 3 with Codeigniter 2.0 so you can use Smarty 3 specific features like template inheritance.
http://ilikekillnerds.com/2010/11/using-smarty-3-in-codeigniter-2-a-really-tiny-ci-library/
Integrating Smarty in CodeIgniter? It is a breeze!
The template system in CodeIgniter is very basic.
Follow these steps for Smarty 3 in CI 3:
Download CodeIgniter 3
Download Smarty 3 and put its content in 'application/third_party/smarty' folder
Create 'Custom_smarty.php' file in 'application/libraries' and add this code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH.'third_party/smarty/Smarty.class.php');
class Custom_smarty extends Smarty {
function __construct()
{
parent::__construct();
$this->setTemplateDir(APPPATH.'views/templates/');
$this->setCompileDir(APPPATH.'views/templates_c/');
}
}
?>
Create 'templates' & 'templates_c' folders inside 'application/views' folder
Create simple 'test.tpl' file in 'application/views/templates' folder
Open 'autoload.php' in 'application/config' folder and add:
$autoload['libraries'] = array('custom_smarty');
And inside a controller: $this->custom_smarty->display('test.tpl');
If you are working on localhost set the permissions: sudo chmod -R 777 templates_c. Otherwhise contact your hosting service, if you catch the error Unable to write file. First be sure templates_c folder exists.
Otherwise you can use another template engine like Twig.

Resources