in2code-de / publications

Follower of EXT:bib to show publications in TYPO3. Im- and export of bibtext and xml files.

Home Page:https://www.in2code.de/agentur/typo3-extensions/publications/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

French Umlaut with curly brackets are still missing

karliwalti opened this issue · comments

At https://github.com/in2code-de/publications/blob/develop/Classes/Utility/BibTexUtility.php#L187 the German Umlaute were added, but the most common French ones are still missing. these are:

{'{e}} and {`{e}} and {^{e}} and {^{o}} and {\c{s}}

the results should be the same as without curly brackets.

commented

Hi Mr. Karlen,
I added a feature branch frenchUmlauts and put in the missing french Umlaute. But as I did not understand well the right writing convention, please have a look at it:
https://github.com/in2code-de/publications/blob/frenchUmlaute/Classes/Utility/BibTexUtility.php#L187

I just opened a pull request for a full commit of missing signs #61

commented

please, can you send me a test set for the relevant bibtex possibilities? Then I can test it and make a pull request ...

Just added a pull request #62 that also fixes #57 in the same file.

Attached the test file (please rename it to .bib
TestLibraryPublications.txt

commented

I testet your file, the special chars are not all converted, see screenshot
Bildschirmfoto 2022-11-03 um 13 50 33

Da passiert noch einiges schief im Moment, welches noch nicht alles nachvollziebar ist. Wahrscheinlich hat dies wieder mit der Reihenfolge in der Tabelle zu tun, analog fix #6d70ece

The issue is that not all programs export bibtex files equally. There are at least 3 ways of outputting special characters. In addition, still some chars were not in the table.
I have now reorganized the array, and added a decoding array that will capture more cases. You can find it in #64 . Please let me know if ti work in your test env too.

commented

hm, die Änderungen machen alles eher noch kaputter...
Bildschirmfoto 2022-11-07 um 16 47 01

commented

so im Frontend:
Bildschirmfoto 2022-11-07 um 16 47 59

Es macht gar nichts...

Welche php version wird da genutzt?
Undf gibt es eine fehlermeldung dazu im typo3 log?

commented

php 7.4.30
es sind keine Fehler diesbezüglich vorhanden, denn er importiert ja erfolgreich, nur wird nichts decodiert..., die Zeichen werden halt so umgesetzt wie importiert.

Bitte

return str_replace(self::$encoded, self::$decoding, $string);

wiefolgt wechseln:
return str_replace(self::$decoding, self::$decoded, $string);

commented

so sieht es viel besser aus :-)
Bildschirmfoto 2022-11-08 um 08 30 49

commented

im FE noch nicht ganz perfekt:
Bildschirmfoto 2022-11-08 um 08 32 46

commented

Für È und Ê hab ich selbst hinbekommen. Das č weiss ich nicht, wie ich das anstellen soll...

Das ş \c{s} war leider noch nicht drinn:

muss das zeichen noch in zeile

'ř','ß','ß','ś','š','Š','Ś','§',
ergänzt werden.
Danach die Zeile mit den "s" vor die zeile mit "c" schieben (natürlich in allen drei arrays).

commented

habs hinbekommen, funzt. :-)
Jetzt fehlt noch, dass die Funktion, die für die Abkürzung der Vornamen zuständig ist, diese auch rendert, wenn der Vornamen mit einem Sonderzeichen beginnt...
Bildschirmfoto 2022-11-08 um 11 22 59

commented

Bildschirmfoto 2022-11-08 um 11 24 30

The full list of latex characters can be found here: https://tug.ctan.org/info/symbols/comprehensive/symbols-a4.pdf
This list is huge, and in case some of them will be used in the abstract, it might be imported wrongly. therefore, I suggest to use a latex engine for the abstract in the future.

commented

ups, seems so.
But for the moment the solution fits much better, than before...

There are still 3 issues to clarify:

  1. Special Char acronym for names: Check whether special char here:
    $name = $name[0] . $this->arguments['suffix'];
  2. A comma and empty space in year brackets for Mörgeli et al: This seems to be a rendering of the month which can deal only with numbers. solution: fix template with either
    <f:if condition="{publication.month}">
    replace "{publication.month}" with <publications:format.monthNameFromNumber month="{publication.month}" limit="3"/> or return characters instead of empty in or remove month from template altogether (best)
  3. There is unfortunately a space after A in Alesund. Likely this is due to a mistake in the template and not the conversion itself: keep as is.
commented

to 3) the space after A in Alesund is in the imported bibfile...

commented

to 2) As far as I remember, the month was included, because of sorting reasons. I will keep it in the template, but try your suggestion.

commented

I have a solution for the issue 2, with the month, I expanded in my local environment the monthNameFromNumber class to catch and format month names, if the importer imports month names as strings, not as numbers.
and for issue 3 also, I put the Templates more inline, then the space dissapears...
Could you provide a solution for issue 1?

Could you try this?

it would also solve #63

    /**
     * @return string
     */
    public function render(): string
    {
        /** Reformat already stored Initials */
        $names_temp=str_replace('.',' ',$this->renderChildren());
        /** Pick initial from each name and stich together with spacer*/
        $names = GeneralUtility::trimExplode(' ', $names_temp, true);
        $initials='';
        foreach ($names as $name) {
            $initials .= $name[0] . $this->arguments['suffix'] . $this->arguments['glue'];
        }
        return rtrim($initials, $this->arguments['glue']);
    }
commented

it solves #63, but not issue 1 of this thread..., see screenshot
Bildschirmfoto 2022-11-24 um 15 02 59

I don´t see the issue at the moment. The function trimExplode seems allright.

Could you try the following 2 outputs?

  1. Add a second name in the benchmark i.e. Mörgeli, Änis Elvira

  2. replace $name[0] with $name in code (only for debugging purpose)

commented

only setting a second Name does not work.
Changing name[0] to name seems to work for special Chars, see screenshot.

Bildschirmfoto 2022-11-25 um 09 11 52

Does setting a second name display ".E.," or nothing like before?

commented

it displays nothing.
I changed the name[0] now with a substr Funktion and set the length of the substring to 3. That gave this interesting picture...

Bildschirmfoto 2022-11-25 um 09 35 18

commented

it seems that special Chars count as 2???
here is my code:
foreach ($names as $name) {
$firstletter = substr($name, 0, 3);
$initials .= $firstletter . $this->arguments['suffix'] . $this->arguments['glue'];
}

Yes it is a multibyte encoding. Unfortunately it does not need to be limited to 2 bytes.
Therefore, third thing to try:
3) replace '$name[0]' with 'mb_substr($name, 0, 1)'

commented

cheerio, it works. :-)

commented

so I make a pull request... :-)

commented

solved with #65