Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix short_version (upper/lower) case priority #972

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Houston4444
Copy link
Contributor

@Houston4444 Houston4444 commented Apr 11, 2025

Replaces #971.

short_version is used in narrow strips to limit the number of letters of strip names or plugin names. Reading its code, something jumped out at me and explain why many times there is nearly no link between the original name and the short name.

This function removes characters until the desired limit is reached.
Originally, It removes characters in this order :

  • white spaces and punctuation
  • lower-case vowels
  • upper-case vowels
  • lower-case consonants
  • upper-case consonants

In this PR, it removes characters in this order:

  • white spaces and punctuation
  • lower-case vowels
  • lower-case consonants
  • upper-case vowels
  • upper-case consonants

Upper case has priority over lower case ! It explain why
ACE Reasonable Synth gave in 5 characters CRsnS (no link with original, instead of ACRsS, not perfect but better). It allows to use CamelCase and have at least the first letter of each word.

Note that "Y" is considered as a consonant, "S" is never removed, I did not change that.

@x42
Copy link
Member

x42 commented Apr 11, 2025

I think we should remove that ancient custom short_version function and instead rely on Pango::EllipsizeMode
which also works for other languages.

@pauldavisthefirst
Copy link
Contributor

My understanding is that Pango ellipsizing is a completely different concept. This one was called "disemvoweling" and comes up with entirely different results. On long text, disemvoweling still makes most languages legible, which ellipszing does not. However, it is possible that on short text (e.g. plugin names), the results are not the same.

@Houston4444
Copy link
Contributor Author

@x42, If we talk about this enum https://docs.gtk.org/Pango/enum.EllipsizeMode.html, I think we are not talking about the same thing. EllipsizeMode only removes the start, the middle or the end of the string. The short_version mechanism is pretty good to recognize an item with fewer characters.
@pauldavisthefirst, Note that, for a good internationalization, it would be nicer to include vowels with accent but there are many (at least 16 in french).

For me, the biggest problem remain the fact narrow strips limits the strip name to 5 characters (https://tracker.ardour.org/view.php?id=6610). I try since few days a build with this limit set to 10, and I have never seen any truncated name. It probably depends on the font though, but I think this limit could be set to 8 without any risk.

@pauldavisthefirst
Copy link
Contributor

The vowel and consonant lists are translatable and can be any size.

@Houston4444
Copy link
Contributor Author

The vowel and consonant lists are translatable and can be any size.

Too many characters, too much work to try to cover many latin languages. example: https://altcodeunicode.com/alt-codes-all-latin-vowel-consonant-letters-with-accents-diacritical-marks/
I could make a global priority to uppercase if std::tolower (and toupper) was giving the lowercase of a letter with accent (exemple: if 'É' becomes 'é' with tolower() as in Python), but it is not the case, and if ever we could, it could be very system specific, so, I won't work on this.

@pauldavisthefirst
Copy link
Contributor

The idea would be, e.g. that the French translation includes tfrnaslations for the vowel list, and the Hungarian translation also, with its own list. There's no need or reason for a unviersal list.

@Houston4444
Copy link
Contributor Author

something like this ?

string lang = std::getenv("LANG");
string sht_lang = lang.substr(0, 2);
string locale_vowels = "";

if (sht_lang == "fr"){
	locale_vowels = "àéèïôùy";
} 
/* others "else if" for other languages */

/* later */
if (locale_vowels.size()){
	while (orig.length() > target_length) {
		if ((pos = orig.find_last_of (_(locale_vowels.c_str()))) == string::npos) {
			break;
		}
		orig.replace (pos, 1, "");
	}
}

@pauldavisthefirst
Copy link
Contributor

we localize strings in ardour with gettext, which means the _() macro

hence _("aeiou") is localizable. no other verbiage necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants