Posted by promes on January 13, 2009 at 5:52pm
| Project: | Typogrify |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | mikl |
| Status: | active |
Issue Summary
I like your module very much and use it in all of my websites. But I made a modification in smartypants.php because in The Netherlands the official start of a word included into quotes is not like "a word" but like „a word”. I changed the closing quote into ” because the only correct starting quote „ has the same appearance.
Is it possible to make a setting to switch from upper starting quote to a lower starting quote. Or better to make it per node language dependent (some of my nodes are in English).
I can send my modifications if you wish.
Comments
#1
Hi Promes,
Thank you for your suggestion. I only just took over maintainership of this module, but I think it's a good idea, and I'll try and implement it in a future release :)
#2
Hi,
I independently hacked smartypants to support German (and eastern European) quotes as default.
The default was used as I was too lazy to do the Drupal part too.
The patch uses „ as opening and “ as closing quote and for single quotes 8218 and 8216, as this seems to be the common use.
It would be nice to see this patch equipped with some user interface in the next revision of the module.
Maybe its worth to send it upstream?
A first step would be to make it filter dependent configurable. That can be used easy on single language pages and even on multilanguage pages it is possible to duplicate the filters for both types of quotes. It's ugly, but it works.
#3
subscribe
#4
I think, you don't need a switch but smartypants should respect the language code of the text. I think with smartypants it is the same with most american products: the originators can not imagine that the world is not american: That dates could have different formats than mm/dd/yy, that weeks can start on mondays, that there are more characters than can fit into 7-bit, that decimal points can be commas and even that opening quotes can be on the base line.
I have tried texy module, that contains the language "switch", but it does it globally, so this approach is not usable in multilingual sites (btw. texy seems to have lost its developer as he does not respond on issues).
I beg the maintainer of typogrify module: add language dependent typografics as soon as possible, please. And this should not be a configurable option, it should be done automatically, so no change in user interface is required. For language independent nodes the site's default language should be used (and that might not be "english").
#5
Rethinking my previous post, I think it is a bug!
#6
#4: Given that I'm in fact not an American, and live in one of those countries where we have non-ASCII letters, use commas for the decimal point, etc., I think I have a fairly good imagination when it comes to stuff that is not American :)
It is not possible with the Drupal 6 API to make language sensitive filters. This has been fixed in Drupal 7, so it might be supported in the coming Typogrify for Drupal 7.
#7
OK, it's not possible in D6 on node level. But it would help a lot if you make it configurable on site level. Most sites are single language so the benefit is large. For me it means I don't have to hack the module anymore and be able to use an official and tested version. I just started to create the first D6 sites: I have to see how I hack the D6 version. I hope the Keinstein (#2) approach will help me to understand smartypants better.
#8
But even with D7 there will be additional problems: If the language changes during text flow (could be possible!) even the node level language won't help.
So, what about a filter tag within the text to switch the rendering of Quotes: something like [sp:de] to render all following text according to german rules, [sp:en], to switch to english rules. If no rule switch is given, the global rules (as requested in #7) apply.
[sp:xx] refers to "smarty pants" :) I would also be happy with [ty:xx] to refer to "typogrify".
Another approach (to be less language dependent) could be to define and name different sets of rules how quotes are rendered and then use this name in the tag, e.g. [sp:upper] and [sp:lowerupper] for rule "upper": make typografic upper quotes and "lowerupper" to make typografic lower and upper quotes. I can imagine, that some people also like «» for quotes!
#9
I don’t think it’s the task of this module to try and reinvent Drupal's multi-lingual system. Being able to switch language mid-text would be a nice features for those few sites that would ever use such a feature, but if it was to be implemented, it should be done in a way suitable for all input filters, not just Typogrify.
#10
Yes, you are right and I fully agree with you. Therefore I added the paragraph about "less language dependent". The author should be able to decide how to render quotes. And with this approach I could fulfill my language needs, too ;)
#11
subscribe
#12
Switching language in the text has always been possible since it's only dependent on a "lang" attribute of some HTML tag. And so it is the task of the filter to recognize it or to ignore it. I don't see a way for Drupal to generally understand which string has which language at which point in the article. BBCode for example has a different syntax Drupal must not deal with. Some filters need the whole input of an article other deal with substrings.
The only help Drupal can do, is to provide some helper functions (e.g. HTML Parser), But such functions can be provided by any module and offered to Drupal core for integration.
I woud prefer a site wide solution if a node language dependent solution can not be achieved. The possibility to select different quoting styles is needed for the node local solutions, anyhow.
Changing Version to 6.x-1.x since site wide solutions need not to be language dependent at all.
#13
Well, for polish users this functionality is needed too. Because we use Drupal for workflow in our magazine, and almost all text processing is done via Drupal, I needed a way to add polish quotes. These two patches add additional filter configuration forms and can convert ,, (two commas) to html 'bdquo', '' (two apostrophs) and " (english quote) to html 'rdquo'. I don't know if missing puctuation table is by design, but these patches add it two.
Now, I can safely import text to Scribus, do basic text processing (like setting text styles etc.) and voila!
#14
It's late so I did small typos, apply #13 than these ones
#15
I've created a patch for 7.x-1.0-rc2 based on keinstein's diff.
It obeys the langcode of the node and switches between ´
EducateGermanQuotes` and `EducateQuotes`.In this version just for german aka de, which other languages uses the lower-ticks? Dutch for sure ...
#16
Hello migmedia,
#15 This is just what I need for a new site with pages in: Dutch, German, English and Spanish.
The Dutch indeed should be included to use the "German"quotes.
But still there will be sites, formally in only one language, with pages in more then one language (so without the $lang variable available) for which there should be another solution. Maybe, as previously suggested, it should be a native Drupal setting per page.
I hope in the near future there will be a official version with the above patches.
I will create a version 6 of patch #15 shortly.
Thanks
#17
@promes: You can find my repo here https://hg.xilab.net/oss/drupal/typogrify/ with the latest changesets.
In d7 the input-filter is aware of the language (for the node or system-default). This
$langcodeis new and described in http://api.drupal.org/api/drupal/modules--filter--filter.api.php/functio... ; For backporting you can't support this feature.Maybe the double-char-quote-input helps out for the multilanguage site. It supports
,,''<<>>.#18
In my previous comment I was wrong: the Dutch use another style of quotes. I didn't have time to use the #2 solution before.
In the attachment I did combine the patch #2 and #15 for Drupal 6 and added a Dutch quotes section, which uses „ as opening and ” as closing quote and for single quotes ‚ and ’. So it automatically switches between default, German and Dutch style depending on the actual Drupal language setting of the node.
I cannot make a diff file (who can give me a hint for a Windows version?). I presume my attachment will be ok for smartypants.php.
To set the actual language in typogrify.module should be changed at two places in function _typogrify_process($text, $format).
At the start of the module (line 84) I added 3 lines:
function _typogrify_process($text, $format) {
global $language;
$ctx = array();
$ctx['langcode'] = $language->language;
$characters_to_convert = array();
and the call to SmartyPants (line 108) has been extended with $ctx:
old:
$text = SmartyPants($text, NULL);new:
$text = SmartyPants($text, NULL, $ctx);#19
I made a mistake in one type of quotes. So here is the update.
So we have now:
English: He said, “‘Quoted’ words in a larger quote. Isn’t this funny?”
German: He said, „‚Quoted‘ words in a larger quote. Isn‘t this funny?“
Dutch: He said, „‘Quoted’ words in a larger quote. Isn’t this funny?”
#20
Discussion:
I have been thinking about the way the quotes now are set, based on the language settings. A language doesn't have only ONE style, the larger the language area the more local differences there will be. And of course there can be a personel / company style.
I think the solution is to implement different styles and be able to define in the module settings what style is wanted per defined language of the site. So the site admin can choose the preferred style per language.
Of course there should be a default style per language.
I think for the now the above solution will do. But if we need a real smart module ...
#21
Now we are able to convert the quotes to the style we like, based on the language setting, but often the input allready contains styled-quotes: ‘, ’, ‚, “, ” and „.
Is there a way to convert these quotes back to the ASCII-characters ' and " so we can style it the preferred way?
I did try a conversion at several places, but didn't succeed.
#22
I've created a new patch with simplified i18n-quotation handling. So we can add easily language-specific quotation-styles.
One line per languange:
<?php
$quotes = array(
'de' => array( 'do' => '„', 'dc' => '“', 'so' => '‚', 'sc' => '‘',),
'en' => array( 'do' => '“', 'dc' => '”', 'so' => '‘', 'sc' => '’',),
'nl' => array( 'do' => '„', 'dc' => '“', 'so' => '‘', 'sc' => '’',),
'ru' => array( 'do' => '«', 'dc' => '»', 'so' => '‘', 'sc' => '’',),
);
?>
The idea of offering a free to choose array is also possible to implement.
#23
The Dutch (nl) dc should be
”like English.I manually changed my version of Smartypants.php with your patch (I don't have a program to apply the patch). Net results: no quotes at all in the output. Maybe I overlooked one of te changes.
I like to hear from others if I made a mistake.