Acronyms


This project is not covered by Drupal’s security advisory policy.

Acronyms is a small module which handles Acronyms (also known as Abbreviations) on your site. The primary function is acronyms_parse_string($string) which takes and returns a string, properly formatted with the acronyms (or abbreviations) in it. This module was created for a client project - we were importing several thousand company names into Drupal and the php command ucwords() did not properly address acronyms/abbreviations (it would turn USA into Usa), so I created this module as a solution to that problem. This module is essentially a text parser, so can be integrated into your theme, a custom block, or your module code (to name a few places).

Depending on the case of the input, the acronyms_parse_string($string) function will return:

If $string is Mixed Case:
"The USA has 48 contiguous states." will return the same string (if "Auto Create" is enabled in Administer >> Acronyms then it will also save the "USA" acronym for future use).

If $string is ALL CAPS:
"THE USA HAS 48 CONTIGUOUS STATES." will return "The USA has 48 Contiguous States." (if the "USA" acronym was added manually or automatically).

If $string is all lower case:
"the usa has 48 contiguous states." will return "The USA has 48 Contiguous States." (same reason as above.)

NOTE
You might notice the word "has" in the above examples is lower case in all three outputs. This is an additional function I added which treats conjunctions, pronouns, and prepositions as "always lowercase, except if they are the first word in the string". Currently this list is hard-coded into the module, but I'm planning to offer configuration of this list of words in a future version.

Example:
(assumes "USA" is defined as an acronym)

// Normally $string would be set programmatically, but this is just an example
$string = 'the usa has 48 contiguous states.';

// See above for specifics on input/return values and how they work.)
$parsed_string = acronyms_parse_string($string);
// $parsed_string = 'The USA has 48 Contiguous States.'; // this is the returned value.

// now we can either use that $parsed_string somewhere (useful for modules), or just output the value to the screen (useful for blocks, themes, etc)
print $parsed_string;

Other Notes:
This module does not currently handle definitions of the acronyms (setting USA = United States of America, for example). If you need that functionality you might check out Glossary.

Please share ideas, suggestions for improvements, code submissions to improve this module further! Thank you.

The 6.x version is released and is fairly stable - please help out by reporting any bugs to the issue queue.


Acronyms项目的Drush安装命令:复制到剪贴板

注:个别模块仍需开启相关子模块。

项目分类:

周安装量: 
2
维护状态: 
未知
开发状态: 
未知