It is currently March 28th, 2024, 3:53 pm

StringCase option Tooltip

Get help with creating, editing & fixing problems with skins
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

StringCase option Tooltip

Post by xenium »

Hi,
Can I use StringCase=Proper for the tooltip ?
Thanks
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: StringCase option Tooltip

Post 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.
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: StringCase option Tooltip

Post 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!
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: StringCase option Tooltip

Post 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".
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: StringCase option Tooltip

Post 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.
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: StringCase option Tooltip

Post 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
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: StringCase option Tooltip

Post 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?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: StringCase option Tooltip

Post 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]
User avatar
Yincognito
Rainmeter Sage
Posts: 7024
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: StringCase option Tooltip

Post 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...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: StringCase option Tooltip

Post by jsmorley »

Post Reply