Page 1 of 2

StringCase option Tooltip

Posted: January 21st, 2020, 2:39 pm
by xenium
Hi,
Can I use StringCase=Proper for the tooltip ?
Thanks

Re: StringCase option Tooltip

Posted: January 21st, 2020, 2:46 pm
by jsmorley
xenium wrote: January 21st, 2020, 2:39 pm Hi,
Can I use StringCase=Proper for the tooltip ?
Thanks
No, you can't. I think that would take some Inline Lua to accomplish.

Re: StringCase option Tooltip

Posted: January 21st, 2020, 2:50 pm
by xenium
jsmorley wrote: January 21st, 2020, 2:46 pm No, you can't. I think that would take some Inline Lua to accomplish.
Thank you!

Re: StringCase option Tooltip

Posted: January 21st, 2020, 2:57 pm
by jsmorley
So like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[Lua]
Measure=Script
ScriptFile=#CURRENTPATH#Test.lua
Disabled=1

[MeasureString]
Measure=String
String=hello world

[MeterString]
Meter=String
MeasureName=MeasureString
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
StringCase=Upper
DynamicVariables=1
ToolTipText=[&Lua:ProperCase('[&MeasureString]')]
Test.lua:

Code: Select all

function ProperCase(inArg)
	return (inArg:gsub('(%S)(%S*)', function(first, rest) return first:upper() .. rest:lower() end))
end


1.png


When using global substitute gsub(), the character class %S in Lua pattern matching simply means "not a space or tab".

Re: StringCase option Tooltip

Posted: January 21st, 2020, 3:34 pm
by xenium
Good thing there is a solution using Lua.

I add in the W10WEnterp skin and the phases of the Moon, and in other languages the first letter is lowercase.
But now I noticed that in some languages the translation also contains prepositions and these should be lowercase.

So I leave the translation as is.

Re: StringCase option Tooltip

Posted: February 10th, 2020, 5:28 pm
by xenium
jsmorley wrote: January 21st, 2020, 2:57 pm So like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[Lua]
Measure=Script
ScriptFile=#CURRENTPATH#Test.lua
Disabled=1

[MeasureString]
Measure=String
String=hello world

[MeterString]
Meter=String
MeasureName=MeasureString
FontSize=15
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
StringCase=Upper
DynamicVariables=1
ToolTipText=[&Lua:ProperCase('[&MeasureString]')]
Test.lua:

Code: Select all

function ProperCase(inArg)
	return (inArg:gsub('(%S)(%S*)', function(first, rest) return first:upper() .. rest:lower() end))
end



1.png



When using global substitute gsub(), the character class %S in Lua pattern matching simply means "not a space or tab".
Using Lua, the text in the tooltip is displayed like this:
11:00 Pm Thu

Is it possible that am and pm to be lowercase?
11:00 pm Thu

Re: StringCase option Tooltip

Posted: February 10th, 2020, 6:11 pm
by balala
xenium wrote: February 10th, 2020, 5:28 pm Using Lua, the text in the tooltip is displayed like this:
11:00 Pm Thu
No. It is displayed as Hello World. Isn't it?

Re: StringCase option Tooltip

Posted: February 10th, 2020, 6:30 pm
by balala
xenium wrote: February 10th, 2020, 5:28 pm Is it possible that am and pm to be lowercase?
11:00 pm Thu
I doubt a .lua script would be needed. A String measure is enough, as far as I can tell:

Code: Select all

[MeasureToolTip]
Measure=String
String=[MeasureString]
RegExpSubstitute=1
Substitute="(?i)am([^a-zA-Z0-9])":"am\1","(?i)pm([^a-zA-Z0-9])":"pm\1"
DynamicVariables=1

[MeasureString]
Measure=String
String=...

[MeterString]
Meter=String
MeasureName=MeasureString
...
ToolTipText=[MeasureToolTip]

Re: StringCase option Tooltip

Posted: February 10th, 2020, 7:02 pm
by Yincognito
If only the PCRE regex in Rainmeter would be the "extended" one. Apparently, according to Regular-Expression, case conversion is possible in the extended version of PCRE2. Even so, I'm not sure it would work for all letters in other languages, so it seems Lua is the only solution for this at this time...

That being said, if the talk is about weather skins, the good thing about weather data is that the number of strings retrieved are limited - meaning you don't have to deal with every word in the dictionary, just a few dozens of them (at most). Having said that, displaying weather data in all/multiple languages complicates things.

Me, I won't bother with localized weather strings. I never did, and I never will. I also use tooltips extensively in my skins and for visual formatting purposes, having a ton of languages to display data in tooltips would be a disaster. I barely managed to make string right align and have the exact length on each tooltip row in English - doing that in other languages would take months and lot of effort to get it right...

Re: StringCase option Tooltip

Posted: February 10th, 2020, 7:09 pm
by jsmorley