Trying to help with How to sentence case every n-th row in Calc? I couldn’t find a way to load a transliteration module capable of applying ‘SentenceCase’. A respective user function based on ordinary string manipulation is rather inefficient, and may not return exactly the same result in every case (not fully tested).
(Moved to the answer by @mikekaganski.)
I suppose that Make a function that will ignore diacritic/accented characters., combined with use of
com.sun.star.i18n.TransliterationModulesExtra.SENTENCE_CASE, may be helpful.
(Hope the body now isn’t still “too similar”…)
I had already found the thread with your old answer you linked to, and had used the module code 200, but didn’t succeed.
New tries always resluted in a transliteration service with .Name = “Not Loaded”.
Different calls to .transliterate or .transliterateString2String with “guessed” parameters didn’t throw an error, but simply returned the passed string.
My raw workaround function based on REGEX and ordinary string manipulations in Basic needed about 1.7 ms per cell with 161 characters and 6 sentences each. With a single letter per cell it was about 0.5 ms per cell. That’s not too bad, but not satisfying.
I once had even trieds the .method
loadModuleByImplName() and in fact it resulted in
oTr.Name = sentence(generic)". but I neither suceeded with getting rid of the “(generic)” nor with getting a reasonable result from the applied (tried) methods. What I actually got was a funny way to write “broken”:
!!br0ken!!. Double exclamation marks and a zero in place of the “o”.
I would suggest you save your time now. My quiestion was mainly a matter of curiosity. I don’t need the working answer urgently.
Have a nice day (tomorrow) …
Heh, let me paste what does work for me - just in case.
sub Foo() dim oLoc as new com.sun.star.lang.Locale, oTr as object oTr = CreateUnoService("com.sun.star.i18n.Transliteration") oTr.loadModuleByImplName("SENTENCE_CASE", oLoc) msgbox oTr.transliterate("abc def GHD", 0, 11, array()) end sub
FTR: this gives me
Abc def ghd.
But if I e.g. replace
12, I indeed get the infamous
You can’t let up?
disask66740SentenceCase_1.ods (16.4 KB)