[sdk/pology] /: fr, add sieve to convert apostrophes according to the French team rules
Johnny Jazeix
null at kde.org
Mon Jun 5 07:20:54 BST 2023
Git commit 00b8de37bad27d448e4b0143dedfddb77c9fe775 by Johnny Jazeix.
Committed on 03/06/2023 at 11:52.
Pushed by jjazeix into branch 'master'.
fr, add sieve to convert apostrophes according to the French team rules
M +9 -0 doc/user/sieving.docbook
M +1 -0 lang/fr/sieve/CMakeLists.txt
A +51 -0 lang/fr/sieve/setApostrophe.py
https://invent.kde.org/sdk/pology/-/commit/00b8de37bad27d448e4b0143dedfddb77c9fe775
diff --git a/doc/user/sieving.docbook b/doc/user/sieving.docbook
index 4abc63c24..8ffdeb9ee 100644
--- a/doc/user/sieving.docbook
+++ b/doc/user/sieving.docbook
@@ -2574,6 +2574,15 @@ Note that percent characters in the <literal>plural-forms</literal> field are es
</sect2>
+<sect2 id="sv-fr:setApostrophe">
+<title><command>fr:setApostrophe</command></title>
+
+<para>In French language, the <literal>’</literal> character is the apostrophe. A rule in the French team is to use directly <literal>'</literal>. <command>fr:setApostrophe</command> will detect the <literal>’</literal> and transform them to <literal>'</literal>.</para>
+
+<para>There are no parameters.</para>
+
+</sect2>
+
<sect2 id="sv-ru:fill-doc-date-kde">
<title><command>ru:fill-doc-date-kde</command></title>
diff --git a/lang/fr/sieve/CMakeLists.txt b/lang/fr/sieve/CMakeLists.txt
index 7f85e8a41..9d4bb3c83 100644
--- a/lang/fr/sieve/CMakeLists.txt
+++ b/lang/fr/sieve/CMakeLists.txt
@@ -1,5 +1,6 @@
set(sieves
setUbsp.py
+ setApostrophe.py
)
get_current_source_subdir(srcsubdir)
install(FILES ${sieves} DESTINATION ${DATA_INSTALL_DIR}/${srcsubdir})
diff --git a/lang/fr/sieve/setApostrophe.py b/lang/fr/sieve/setApostrophe.py
new file mode 100644
index 000000000..52fbf4822
--- /dev/null
+++ b/lang/fr/sieve/setApostrophe.py
@@ -0,0 +1,51 @@
+# -*- coding: UTF-8 -*-
+
+"""
+Replace apostrophe (’) with the ' according to the French rules.
+
+Documented in C{doc/user/sieving.docbook}.
+
+ at author: Johnny Jazeix <jazeix at gmail.com>
+ at license: GPLv3"""
+
+import re
+
+from pology import _, n_
+from pology.report import report
+
+
+def setup_sieve (p):
+
+ p.set_desc(_("@info sieve description",
+ "Replace apostrophe (’) with the ' symbol."))
+
+
+class Sieve (object):
+ """Replace ’ by ' when needed"""
+
+ def __init__ (self, params):
+ self.nmatch = 0
+
+ def process (self, msg, cat):
+
+ oldcount=msg.modcount
+
+ for i in range(len(msg.msgstr)):
+ msg.msgstr[i]=self.setApostrophe(msg.msgstr[i])
+
+ if oldcount<msg.modcount:
+ self.nmatch+=1
+
+ def finalize (self):
+
+ if self.nmatch > 0:
+ report(n_("@info",
+ "Apostrophes updated in %(num)d message.",
+ "Apostrophes updated in %(num)d messages.",
+ num=self.nmatch))
+
+ def setApostrophe(self, text):
+ """Set correctly apostrophes"""
+ text=text.replace("’", "'")
+
+ return text
More information about the kde-doc-english
mailing list