ExpressionEngine Word Limiter and Norwegian typography
5 April, 2011 | Filed under “ExpressionEngine”
Note: The following has been tested with Word Limiter version 1.0 in ExpressionEngine 1.6.9 Core.
The EllisLab Word Limiter plugin for ExpressionEngine will, by default, add an ellipsis (…) at the end of whatevet number of words specified for a given text field, like so:
This field of text has been limited to ten words…
Typographic rules for the Norwegian language call for an empty space between a word and an ellipsis (in Norwegian, ellipse, or in everyday speech, prikk–prikk–prikk), like so:
words …
How do we achieve this with the American plugin? As it turns out, we do not achieve it with the plugin at all. Instead, we have to dig into a system file and make some adjustments there. Navigate to:
/system/core/core.functions.php
Note: Security-wise you may have renamed the default system folder when you originally installed ExpressionEngine. Hence, the system folder may have a different name.
1. Duplicate core.functions.php and archive the original file elsewhere.
2. Return to the duplicate and make sure that the file’s name is equal to the original’s.
3. Open the duplicate in a “web safe” word processor and search for the line:
return trim($str).'…';
It sits below the Word limiter comment; in ExpressionEngine 1.6.9 Core it is line 820.
The … part is the Unicode character encoding for an ellipsis. It is fairly safe to use as most type designers include it with their font glyphs.
4. The quick and dirty fix for Norwegian web sites would be to type a space between the singe quote and the ampersand, like so:
return trim($str).' …';
However, this way you may end up with a line break between the last word and the ellipsis, leaving the ellipsis orphaned on the last line of text.
A better approach is to make sure that the last word drops down together with the ellipsis, like so:
words …
The code should read:
return trim($str).' …';
where   is a non-breaking space (aka )
5. Save the file.
6. Check that the new file works as expected.