Closed (fixed)
Project:
Easy Breadcrumb
Version:
7.x-2.12
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Dec 2016 at 19:55 UTC
Updated:
25 Jul 2017 at 15:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
greg boggsT 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.
Comment #3
j_s commentedIf 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?
Comment #4
greg boggsAhh. Sorry, I didn't realize you were on the old version.
The 7.x branch already has the Capitalizor implemented.
Comment #5
j_s commentedThe 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.
Comment #6
greg boggsThe 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.
Comment #7
j_s commentedComment #8
j_s commentedI see, sorry to hear 7.x is basically frozen. Thanks for the support!
Comment #9
greg boggsI'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.
Comment #10
tatarbjHi 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.
Comment #11
tatarbjHi 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.
Comment #12
greg boggsLooks good! Can you detail a test case so I can be sure I'm testing this code well?
Comment #13
tatarbjHi @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.
Comment #14
j_s commentedWorks great, thanks!!
A couple things:
Thanks for your work on making this a possibility! I really appreciate it!
Comment #15
tatarbjHi @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.
Comment #16
tatarbjComment #17
j_s commentedPerhaps 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!
Comment #18
tatarbjHi @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.
Comment #19
tatarbjI've rerolled the last patch on the new 7.x-2.x branch.
Waiting for review :)
Comment #20
tatarbjComment #22
tatarbjComment #23
tatarbj