In my URLs, I have some acronyms of organizations that need to be all uppercased.

I could use String Overrides module, but it only works for strings passed through t(). In _easy_breadcrumb_normalize_text(), would changing return $normalized_text; to return t($normalized_text); work ok, or is there a reason t() isn't used?

Thanks!

Comments

Prizem created an issue. See original summary.

greg boggs’s picture

T is only meant for translation of strings. It's not meant to be used for capitalization needs. Instead, there's currently code for capitalization that's been stubbed out in the module. But, it hasn't been implemented yet. The basic idea is that you can set the strings to capitalize on the crumb configuration screen, then those should be used when building the crumbs.

This is still an open todo.

j_s’s picture

If t is meant for translation, would it make sense to apply t to breadcrumbs to enable translation? And besides its purpose, String Overrides is a useful module that takes advantage of it.

But glad there's already a capitalization scheme in the works! Will it be implemented for 7.x?

greg boggs’s picture

Ahh. Sorry, I didn't realize you were on the old version.

The 7.x branch already has the Capitalizor implemented.

j_s’s picture

The Capitalizor that's there isn't sufficient to selectively uppercase specific words. There's none, capitalize first letter of each word, or capitalize first letter of each segment. I need to uppercase specific whole words, e.g. foobar becomes FOOBAR, or foobar foods becomes FOOBAR Foods (with "capitalize first letter of each word" selected).

The "Words to be ignored by the 'capitalizator'" is also not sufficient as it's only applied to "words not at the beginning of each segment". In a segment with only one word that needs to be uppercase (foobar), that one word still gets capitalized (Foobar). Even if it could ignored, I assume it'd be left as lowercase (foobar), when I actually need it to be all uppercase (FOOBAR).

Easiest solution would be to apply t and use String Overrides.

greg boggs’s picture

The difficulty with applying t() is that it would make duplicate strings available to translators which is already super confusing as it is in D7. You could do that with a patch in your local project. But, we can't do that in the contrib version. Instead, we could expand the capitalizer to support full word caps. Development is basically frozen on the D7 branch. So, it's unlikely that any patches you make will be broken in the future.

j_s’s picture

Version: 7.x-1.x-dev » 7.x-2.12
j_s’s picture

I see, sorry to hear 7.x is basically frozen. Thanks for the support!

greg boggs’s picture

I'm happy to assist if someone wants to pick up support of the 7.x code base again. D7 will last 4-5 more years. So, it's worth doing.

tatarbj’s picture

Assigned: Unassigned » tatarbj
Status: Active » Needs work

Hi guys,

@Prizem - the main purpose of t() is to make strings translatable that are not variables. https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/t/7.x I would suggest to use format_string() instead. But let me turn back here in a few days with a patch, ok? :)

@Greg - i just started to take a look on the issues here, hope it's useful for you and for others :)

Cheers,
Balazs.

tatarbj’s picture

Assigned: tatarbj » Unassigned
Status: Needs work » Needs review
StatusFileSize
new7.52 KB

Hi all,
sorry for the long delay, but now i'd finally like to show you the patch that solves the need, described by @Prizem.
Let me ask some review on it :)
Cheers,
Balazs.

greg boggs’s picture

Looks good! Can you detail a test case so I can be sure I'm testing this code well?

tatarbj’s picture

Hi @Greg,
here is a test case that i used:
Create a new content (basic page) and set the url: once-a-time/brave-new-world
Then change the easy-breadcrumb settings and try all of them with checking the content's page where you make the block visible.
The following choices you have under 'Transformation mode for the segments' titles' select:
- None (didn't change)
- Capitalize the first letter of each word in the segment (didn't change)
- Only capitalize the first letter of each segment (didn't change)
- Capitalize all the letters of each word in the segment (new option) -> if you choose this one, the breadcrumb should be: Home >> ONCE A TIME >> Brave new world (where my content's title is 'Brave new world')
- Capitalize only the words that are set below (new option) -> If you choose this one, the ignore textarea has to disappear and a new one will be shown called 'Words to be forced to capitalized by the 'capitalizator'' where put time word to make only that one capitalize. Below the textarea, there has to be a checkbox saying 'Make the first letters of each segment capitalized.' By default it's checked. If you used these settings, the breadcrumb should be: Home >> Once a TIME >> Brave new world (if you uncheck the checkbox: Home >> once a TIME >> Brave new world)
I hope it solves the original need :)
Cheers,
Balazs.

j_s’s picture

Works great, thanks!!

A couple things:

  • I see the checkbox appear saying "Make the first letters of each segment capitalized." when "Capitalize only the words that are set below" is selected. Unchecking that box and saving saves the setting, but going back to it, it still appears checked when it should appear unchecked.
  • Not totally necessary, but a checkbox or something to check/uncheck case sensitivity would be neat.

Thanks for your work on making this a possibility! I really appreciate it!

tatarbj’s picture

Hi @Prizem,
thanks for your feedback!
As now i'm not close to my computer, i'll fix the mentioned issue in Wednesday and post the new patch here!
Could you give me an example how should i imagine the case sensitivity that could make you even more satisfied? :)
Cheers,
Balazs.

tatarbj’s picture

Assigned: Unassigned » tatarbj
Status: Needs review » Needs work
j_s’s picture

Perhaps a checkbox above "Make the first letters of each segment capitalized." could appear when "Capitalize only the words that are set below" is selected and could say "Use case sensitivity when matching words to be forced to capitalization by the 'capitalizator'" or something like that.

Then, if checked, it would, for example, match drupal with drupal, druPAL with druPAL. Unchecked, it would match drupal with Drupal, drupal with druPAL. Up to you if it's checked or unchecked by default.

Again, this is just a secondary consideration. The main fix works excellently! Thanks!

tatarbj’s picture

Assigned: tatarbj » Unassigned
Status: Needs work » Needs review
StatusFileSize
new9.77 KB

Hi @Prizem,
i hope i understood your request as you meant :)
Here is a fix for the default status of the checkbox and also has the improvement for the case sensitivity.
How i tested (hopefully it helps to make it RTBC)
- Create a content with the following url: once-a-Time-in-DRUpal/brave-new-world (my content's title is Brave new world)
- Test the following settings of easy_breadcrumb when you choose 'Capitalize only the words that are set below' option:
Set the words in "Words to be forced to capitalized by the 'capitalizator'" textarea: druPAL Time
When you check 'Use case sensitivity when matching words to be forced to capitalization.' checkbox, the result should be: once a TIME in DRUpal (if you make the second checkbox also checked: Once a TIME in DRUpal) in the breadcrumb block.
When you uncheck 'Use case sensitivity when matching words to be forced to capitalization.' checkbox, the result should be: once a TIME in DRUPAL (if you make the second checkbox also checked: Once a TIME in DRUPAL) in the breadcrumb block.

Let me know if i missed something or it doesn't work as you expect!

Bests,
Balazs.

tatarbj’s picture

StatusFileSize
new9.54 KB

I've rerolled the last patch on the new 7.x-2.x branch.
Waiting for review :)

tatarbj’s picture

tatarbj’s picture

Status: Needs review » Reviewed & tested by the community
tatarbj’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.