← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~dholbach/help-app/1433210 into lp:help-app

 

Daniel Holbach has proposed merging lp:~dholbach/help-app/1433210 into lp:help-app.

Commit message:
Readd .link-cta-ubuntu so we can use it to more prominently point out call to action links. This will also allow us to add more attr_list (https://pythonhosted.org/Markdown/extensions/attr_list.html) statements.

The CTA links now work in the web version, on the app version we're still blocked on bug 1433532.

Requested reviews:
  Ubuntu Help app developers (help-app-dev)
Related bugs:
  Bug #1433210 in Ubuntu Help App: "Reenable .link-cta-ubuntu"
  https://bugs.launchpad.net/help-app/+bug/1433210

For more details, see:
https://code.launchpad.net/~dholbach/help-app/1433210/+merge/261228

Readd .link-cta-ubuntu so we can use it to more prominently point out call to action links. This will also allow us to add more attr_list (https://pythonhosted.org/Markdown/extensions/attr_list.html) statements.

The CTA links now work in the web version, on the app version we're still blocked on bug 1433532.
-- 
Your team Ubuntu Help app developers is requested to review the proposed merge of lp:~dholbach/help-app/1433210 into lp:help-app.
=== modified file 'content/pages/index.md'
--- content/pages/index.md	2015-03-19 11:10:25 +0000
+++ content/pages/index.md	2015-06-05 13:39:41 +0000
@@ -7,6 +7,7 @@
   * Tips and tricks to make you more productive
   * Links to get in touch with experts and other community members
 
-[Take me to the FAQ!]({filename}faq.md)
-
-[Get in touch]({filename}get-in-touch.md)
+[Take me to the FAQ!]({filename}faq.md){: .link-cta-ubuntu}
+
+[Get in touch]({filename}get-in-touch.md){: .link-cta-ubuntu}
+

=== modified file 'internals/pelicanconf.py'
--- internals/pelicanconf.py	2015-05-13 14:55:10 +0000
+++ internals/pelicanconf.py	2015-06-05 13:39:41 +0000
@@ -62,7 +62,7 @@
 ]
 
 Q_AND_A_CLASSES = [
-    '!!QA',
+    ' !!QA',
 ]
 
 HIDE_FROM_POT = Q_AND_A_CLASSES + [

=== modified file 'internals/tests/test_translations.py'
--- internals/tests/test_translations.py	2015-03-31 11:44:11 +0000
+++ internals/tests/test_translations.py	2015-06-05 13:39:41 +0000
@@ -1,27 +1,49 @@
+import os
+import shutil
+import tempfile
 from unittest import TestCase
 
-from translations.build import Translations
+from translations.build import Translations, POFile
+from translations.utils import use_top_level_dir
 from pelicanconf import HIDE_FROM_POT
 
 
+class MockPOFile():
+    def __init__(self, po):
+        # copy out .pot file to a temp directory as a basis
+        pwd = use_top_level_dir()
+        self.tempdir = tempfile.mkdtemp()
+        shutil.copy(po.pot_fn, self.tempdir)
+        self.fn = os.path.join(self.tempdir, os.path.basename(po.pot_fn))
+        self.pofile = POFile(self.fn)
+        os.chdir(pwd)
+
+    def __del__(self):
+        if os.path.exists(self.tempdir):
+            shutil.rmtree(self.tempdir)
+
+
 class HelpTestCase(TestCase):
     def __init__(self, *args):
         self.translations = Translations()
+        self.po = self.translations.po
         TestCase.__init__(self, *args)
 
     def test_docs_start_with_title_line(self):
-        po = self.translations.po
-        self.assertTrue(po.gettextize(self.translations.documents))
+        self.assertTrue(self.po.gettextize(self.translations.documents))
         results = []
-        for entry, first_line in po.pot_file_ob.find_title_lines():
+        for entry, first_line in self.po.pot_file_ob.find_title_lines():
             results += [entry.msgid.startswith(first_line)]
         self.assertNotIn(False, results)
 
+    def test_load_mock_pofile(self):
+        mock_pofile = MockPOFile(self.po)
+        self.assertIsNotNone(mock_pofile.pofile)
+
     def test_translated_filenames_in_markdown_links(self):
-        po = self.translations.po
-        for po_fn in po.langs:
-            po.load_pofile(po_fn)
-            pofile = po.langs[po_fn]['pofile']
+        for po_fn in self.po.langs:
+            self.po.load_pofile(po_fn)
+            pofile = self.po.langs[po_fn]['pofile']
             for entry in pofile.find_in_msgid('{filename}'):
                 (link_msgid, link_msgstr) = \
                     pofile.find_link_in_markdown_message(entry)
@@ -29,15 +51,14 @@
                         if doc.endswith(link_msgid)]:
                     self.assertNotIn(link_msgid, link_msgstr)
                     self.assertEqual(1, len(link_msgstr))
-                    self.assertIn(po.langs[po_fn]['bcp47'],
+                    self.assertIn(self.po.langs[po_fn]['bcp47'],
                                   link_msgstr[0])
 
     def test_markup_in_po_or_pot_files(self):
-        po = self.translations.po
-        files = [po.pot_file_ob]
-        for po_fn in po.langs:
-            po.load_pofile(po_fn)
-            files += [po.langs[po_fn]['pofile']]
+        files = [self.po.pot_file_ob]
+        for po_fn in self.po.langs:
+            self.po.load_pofile(po_fn)
+            files += [self.po.langs[po_fn]['pofile']]
         for po_file in files:
             for tag in HIDE_FROM_POT:
                 self.assertEqual(po_file.find_in_msgid(tag), [])

=== modified file 'internals/translations/build.py'
--- internals/translations/build.py	2015-05-13 17:04:59 +0000
+++ internals/translations/build.py	2015-06-05 13:39:41 +0000
@@ -84,17 +84,17 @@
                             self.pofile.fuzzy_entries(),
                             self.pofile.untranslated_entries()]:
             for entry in entry_group:
-                for statement in HIDE_FROM_POT:
-                    if statement in entry.comment:
-                        entries += [entry]
+                if entry.comment in HIDE_FROM_POT:
+                    entries += [entry]
         for entry in entries:
             if not entry.msgid.endswith(entry.comment):
-                entry.msgid += ' %s' % entry.comment
+                entry.msgid += entry.comment
             if entry.msgstr and not entry.msgstr.endswith(entry.comment):
-                entry.msgstr += ' %s' % entry.comment
+                entry.msgstr += entry.comment
             entry.comment = ''
         self.save()
 
+    # Make sure META_TAGS are not accidentally translated
     def safeguard_meta_tags(self):
         for tag in META_TAGS:
             for entry in self.find_in_msgid(tag):
@@ -132,16 +132,34 @@
         link_msgstr = list(re.findall(link_regex, entry.msgstr))
         return (link_msgid, link_msgstr)
 
+    # All markdown links in the po file (everything starting with {filename}
+    # need to be handled with care.
+    # 1) In the case of Spanish translations, we want for example
+    #    'faq.es.md' instead 'faq.md'.
+    # 2) If we mark a link with an attr_list tag, like {: .link-cta-ubuntu},
+    #    this also needs to be preserved.
+    #
     def rewrite_links(self, documents, bcp47):
+
+        # In this specific po file, find all markdown links
         for entry in self.find_in_msgid('{filename}'):
             (link_msgid, link_msgstr) = \
                 self.find_link_in_markdown_message(entry)
+
+            # Find all links which are part of our documents (filter out
+            # images, etc.)
             if [doc for doc in documents.docs if doc.endswith(link_msgid)]:
                 translated_doc_fn = os.path.basename(
                     documents.translated_doc_fn(link_msgid, bcp47))
+
+                # If the translation part of the message does not exist,
+                # just use the msgid
                 if not link_msgstr:
                     entry.msgstr = entry.msgid
                     link_msgstr = [link_msgid]
+
+                # Rewrite filename part of the translated text.
+                # This keeps the label translated, if it already is.
                 entry.msgstr = entry.msgstr.replace(link_msgstr[0],
                                                     translated_doc_fn)
         self.save()

=== modified file 'po/de.po'
--- po/de.po	2015-06-05 07:41:28 +0000
+++ po/de.po	2015-06-05 13:39:41 +0000
@@ -7,7 +7,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-06-04 09:48+0200\n"
+"POT-Creation-Date: 2015-06-04 17:47+0200\n"
 "PO-Revision-Date: 2015-06-04 16:05+0000\n"
 "Last-Translator: Daniel Holbach <daniel.holbach@xxxxxxxxxx>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -122,13 +122,13 @@
 "Links um in Kontakt mit Experten und anderen aus der Ubuntu Gemeinschaft zu "
 "kommen"
 
-#. type: Plain text
+#. {: .link-cta-ubuntu}
 #: content/pages/index.md:11
 msgid "[Take me to the FAQ!]({filename}faq.md)"
 msgstr "[Bringen Sie mich zur FAQ!]({filename}faq.de.md)"
 
-#. type: Plain text
-#: content/pages/index.md:12
+#. {: .link-cta-ubuntu}
+#: content/pages/index.md:13
 msgid "[Get in touch]({filename}get-in-touch.md)"
 msgstr "[Kontakt]({filename}get-in-touch.de.md)"
 

=== modified file 'po/es.po'
--- po/es.po	2015-06-05 07:41:28 +0000
+++ po/es.po	2015-06-05 13:39:41 +0000
@@ -7,10 +7,11 @@
 msgstr ""
 "Project-Id-Version: ubuntu-devices-help\n"
 "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
-"POT-Creation-Date: 2015-06-04 09:48+0200\n"
+"POT-Creation-Date: 2015-06-04 17:47+0200\n"
 "PO-Revision-Date: 2015-06-03 22:30+0000\n"
 "Last-Translator: David Gámiz Jiménez <david.gamiz@xxxxxxxxx>\n"
 "Language-Team: Spanish <es@xxxxxx>\n"
+"Language: es\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -109,13 +110,13 @@
 msgid "Links to get in touch with experts and other community members"
 msgstr ""
 
-#. type: Plain text
+#. {: .link-cta-ubuntu}
 #: content/pages/index.md:11
 msgid "[Take me to the FAQ!]({filename}faq.md)"
 msgstr "[Take me to the FAQ!]({filename}faq.es.md)"
 
-#. type: Plain text
-#: content/pages/index.md:12
+#. {: .link-cta-ubuntu}
+#: content/pages/index.md:13
 msgid "[Get in touch]({filename}get-in-touch.md)"
 msgstr "[Get in touch]({filename}get-in-touch.es.md)"
 

=== modified file 'po/fr.po'
--- po/fr.po	2015-06-05 07:41:28 +0000
+++ po/fr.po	2015-06-05 13:39:41 +0000
@@ -7,10 +7,11 @@
 msgstr ""
 "Project-Id-Version: ubuntu-devices-help\n"
 "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
-"POT-Creation-Date: 2015-06-04 09:48+0200\n"
+"POT-Creation-Date: 2015-06-04 17:47+0200\n"
 "PO-Revision-Date: 2015-02-27 12:21+0000\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: French <fr@xxxxxx>\n"
+"Language: fr\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -107,13 +108,13 @@
 msgid "Links to get in touch with experts and other community members"
 msgstr ""
 
-#. type: Plain text
+#. {: .link-cta-ubuntu}
 #: content/pages/index.md:11
 msgid "[Take me to the FAQ!]({filename}faq.md)"
 msgstr "[Take me to the FAQ!]({filename}faq.fr.md)"
 
-#. type: Plain text
-#: content/pages/index.md:12
+#. {: .link-cta-ubuntu}
+#: content/pages/index.md:13
 msgid "[Get in touch]({filename}get-in-touch.md)"
 msgstr "[Get in touch]({filename}get-in-touch.fr.md)"
 

=== modified file 'po/help.pot'
--- po/help.pot	2015-06-05 07:41:28 +0000
+++ po/help.pot	2015-06-05 13:39:41 +0000
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2015-06-05 09:40+0200\n"
+"POT-Creation-Date: 2015-06-05 12:37+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@xxxxxx>\n"
@@ -106,13 +106,13 @@
 msgid "Links to get in touch with experts and other community members"
 msgstr ""
 
-#. type: Plain text
+#. {: .link-cta-ubuntu}
 #: content/pages/index.md:11
 msgid "[Take me to the FAQ!]({filename}faq.md)"
 msgstr ""
 
-#. type: Plain text
-#: content/pages/index.md:12
+#. {: .link-cta-ubuntu}
+#: content/pages/index.md:13
 msgid "[Get in touch]({filename}get-in-touch.md)"
 msgstr ""
 

=== modified file 'po/it.po'
--- po/it.po	2015-06-05 07:41:28 +0000
+++ po/it.po	2015-06-05 13:39:41 +0000
@@ -7,10 +7,11 @@
 msgstr ""
 "Project-Id-Version: ubuntu-devices-help\n"
 "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
-"POT-Creation-Date: 2015-06-04 09:48+0200\n"
+"POT-Creation-Date: 2015-06-04 17:47+0200\n"
 "PO-Revision-Date: 2015-03-05 11:21+0000\n"
 "Last-Translator: Silvia Bindelli <silvia.bindelli@xxxxxxxxxxxxx>\n"
 "Language-Team: Italian <it@xxxxxx>\n"
+"Language: it\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -109,13 +110,13 @@
 msgid "Links to get in touch with experts and other community members"
 msgstr ""
 
-#. type: Plain text
+#. {: .link-cta-ubuntu}
 #: content/pages/index.md:11
 msgid "[Take me to the FAQ!]({filename}faq.md)"
 msgstr "[Take me to the FAQ!]({filename}faq.it.md)"
 
-#. type: Plain text
-#: content/pages/index.md:12
+#. {: .link-cta-ubuntu}
+#: content/pages/index.md:13
 msgid "[Get in touch]({filename}get-in-touch.md)"
 msgstr "[Get in touch]({filename}get-in-touch.it.md)"
 

=== modified file 'po/pl.po'
--- po/pl.po	2015-06-05 07:41:28 +0000
+++ po/pl.po	2015-06-05 13:39:41 +0000
@@ -7,10 +7,11 @@
 msgstr ""
 "Project-Id-Version: help-app\n"
 "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
-"POT-Creation-Date: 2015-06-04 09:48+0200\n"
+"POT-Creation-Date: 2015-06-04 17:47+0200\n"
 "PO-Revision-Date: 2015-05-15 13:17+0000\n"
 "Last-Translator: Bartosz Kosiorek <Unknown>\n"
 "Language-Team: Polish <pl@xxxxxx>\n"
+"Language: pl\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -107,13 +108,13 @@
 msgid "Links to get in touch with experts and other community members"
 msgstr ""
 
-#. type: Plain text
+#. {: .link-cta-ubuntu}
 #: content/pages/index.md:11
 msgid "[Take me to the FAQ!]({filename}faq.md)"
 msgstr "[Take me to the FAQ!]({filename}faq.pl.md)"
 
-#. type: Plain text
-#: content/pages/index.md:12
+#. {: .link-cta-ubuntu}
+#: content/pages/index.md:13
 msgid "[Get in touch]({filename}get-in-touch.md)"
 msgstr "[Get in touch]({filename}get-in-touch.pl.md)"
 

=== modified file 'po/pt.po'
--- po/pt.po	2015-06-05 07:41:28 +0000
+++ po/pt.po	2015-06-05 13:39:41 +0000
@@ -7,10 +7,11 @@
 msgstr ""
 "Project-Id-Version: ubuntu-devices-help\n"
 "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
-"POT-Creation-Date: 2015-06-04 09:48+0200\n"
+"POT-Creation-Date: 2015-06-04 17:47+0200\n"
 "PO-Revision-Date: 2015-03-19 00:27+0000\n"
 "Last-Translator: Ivo Xavier <ivofernandes12@xxxxxxxxx>\n"
 "Language-Team: Portuguese <pt@xxxxxx>\n"
+"Language: pt\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -109,13 +110,13 @@
 msgid "Links to get in touch with experts and other community members"
 msgstr ""
 
-#. type: Plain text
+#. {: .link-cta-ubuntu}
 #: content/pages/index.md:11
 msgid "[Take me to the FAQ!]({filename}faq.md)"
 msgstr "[Take me to the FAQ!]({filename}faq.pt.md)"
 
-#. type: Plain text
-#: content/pages/index.md:12
+#. {: .link-cta-ubuntu}
+#: content/pages/index.md:13
 msgid "[Get in touch]({filename}get-in-touch.md)"
 msgstr "[Get in touch]({filename}get-in-touch.pt.md)"
 

=== modified file 'po/ro.po'
--- po/ro.po	2015-06-05 07:41:28 +0000
+++ po/ro.po	2015-06-05 13:39:41 +0000
@@ -7,10 +7,11 @@
 msgstr ""
 "Project-Id-Version: ubuntu-devices-help\n"
 "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
-"POT-Creation-Date: 2015-06-04 09:48+0200\n"
+"POT-Creation-Date: 2015-06-04 17:47+0200\n"
 "PO-Revision-Date: 2015-02-27 11:15+0000\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: Romanian <ro@xxxxxx>\n"
+"Language: ro\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -107,13 +108,13 @@
 msgid "Links to get in touch with experts and other community members"
 msgstr ""
 
-#. type: Plain text
+#. {: .link-cta-ubuntu}
 #: content/pages/index.md:11
 msgid "[Take me to the FAQ!]({filename}faq.md)"
 msgstr "[Take me to the FAQ!]({filename}faq.ro.md)"
 
-#. type: Plain text
-#: content/pages/index.md:12
+#. {: .link-cta-ubuntu}
+#: content/pages/index.md:13
 msgid "[Get in touch]({filename}get-in-touch.md)"
 msgstr "[Get in touch]({filename}get-in-touch.ro.md)"
 

=== modified file 'po/ru.po'
--- po/ru.po	2015-06-05 07:41:28 +0000
+++ po/ru.po	2015-06-05 13:39:41 +0000
@@ -7,10 +7,11 @@
 msgstr ""
 "Project-Id-Version: help-app\n"
 "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
-"POT-Creation-Date: 2015-06-04 09:48+0200\n"
+"POT-Creation-Date: 2015-06-04 17:47+0200\n"
 "PO-Revision-Date: 2015-04-29 13:02+0000\n"
 "Last-Translator: Aleksey Kabanov <Unknown>\n"
 "Language-Team: Russian <ru@xxxxxx>\n"
+"Language: ru\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -107,13 +108,13 @@
 msgid "Links to get in touch with experts and other community members"
 msgstr ""
 
-#. type: Plain text
+#. {: .link-cta-ubuntu}
 #: content/pages/index.md:11
 msgid "[Take me to the FAQ!]({filename}faq.md)"
 msgstr "[Take me to the FAQ!]({filename}faq.ru.md)"
 
-#. type: Plain text
-#: content/pages/index.md:12
+#. {: .link-cta-ubuntu}
+#: content/pages/index.md:13
 msgid "[Get in touch]({filename}get-in-touch.md)"
 msgstr "[Get in touch]({filename}get-in-touch.ru.md)"
 


Follow ups