Changeset View
Changeset View
Standalone View
Standalone View
src/docbookl10nhelper.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 50 | { | |||
---|---|---|---|---|---|
52 | QFile outFile(fname); | 52 | QFile outFile(fname); | ||
53 | if (! outFile.open(QIODevice::WriteOnly)) { | 53 | if (! outFile.open(QIODevice::WriteOnly)) { | ||
54 | qCCritical(KDocToolsLog) << QStringLiteral("Could not write %1") | 54 | qCCritical(KDocToolsLog) << QStringLiteral("Could not write %1") | ||
55 | .arg(outFile.fileName()); | 55 | .arg(outFile.fileName()); | ||
56 | return (1); | 56 | return (1); | ||
57 | } | 57 | } | ||
58 | 58 | | |||
59 | QTextStream outStream(&outFile); | 59 | QTextStream outStream(&outFile); | ||
60 | outStream << "<?xml version='1.0'?>" << endl; | 60 | outStream << "<?xml version='1.0'?>\n"; | ||
61 | outStream << QStringLiteral("<!DOCTYPE l:i18n SYSTEM \"%1\" [") | 61 | outStream << QStringLiteral("<!DOCTYPE l:i18n SYSTEM \"%1\" [") | ||
62 | .arg(dtdPath) << endl; | 62 | .arg(dtdPath) << QLatin1Char('\n'); | ||
63 | 63 | | |||
64 | LangListType::const_iterator i = langMap.constBegin(); | 64 | LangListType::const_iterator i = langMap.constBegin(); | ||
65 | while (i != langMap.constEnd()) { | 65 | while (i != langMap.constEnd()) { | ||
66 | //qCDebug(KDocToolsLog) << (*i).first << ": " << (*i).second; | 66 | //qCDebug(KDocToolsLog) << (*i).first << ": " << (*i).second; | ||
67 | outStream << QStringLiteral("<!ENTITY %1 SYSTEM \"%2\">") | 67 | outStream << QStringLiteral("<!ENTITY %1 SYSTEM \"%2\">") | ||
68 | .arg((*i).first).arg((*i).second) << endl; | 68 | .arg((*i).first).arg((*i).second) << QLatin1Char('\n'); | ||
69 | ++i; | 69 | ++i; | ||
70 | } | 70 | } | ||
71 | outStream << "]>" << endl; | 71 | outStream << "]>\n"; | ||
72 | 72 | | |||
73 | if (!langMap.isEmpty()) { | 73 | if (!langMap.isEmpty()) { | ||
74 | outStream | 74 | outStream | ||
75 | << "<l:i18n xmlns:l=\"http://docbook.sourceforge.net/xmlns/l10n/1.0\">" | 75 | << "<l:i18n xmlns:l=\"http://docbook.sourceforge.net/xmlns/l10n/1.0\">\n"; | ||
76 | << endl; | | |||
77 | i = langMap.constBegin(); | 76 | i = langMap.constBegin(); | ||
78 | while (i != langMap.constEnd()) { | 77 | while (i != langMap.constEnd()) { | ||
79 | outStream << QStringLiteral("&%1;") | 78 | outStream << QStringLiteral("&%1;") | ||
80 | .arg((*i).first) << endl; | 79 | .arg((*i).first) << QLatin1Char('\n'); | ||
81 | ++i; | 80 | ++i; | ||
82 | } | 81 | } | ||
83 | outStream << "</l:i18n>" << endl; | 82 | outStream << "</l:i18n>\n"; | ||
84 | } | 83 | } | ||
85 | 84 | | |||
86 | outFile.close(); | 85 | outFile.close(); | ||
87 | 86 | | |||
88 | return (0); | 87 | return (0); | ||
89 | } | 88 | } | ||
90 | 89 | | |||
91 | int writeLangFileNew(const QString &fname, const QString &dtdPath, | 90 | int writeLangFileNew(const QString &fname, const QString &dtdPath, | ||
92 | const LangListType &langMap) | 91 | const LangListType &langMap) | ||
93 | { | 92 | { | ||
94 | 93 | | |||
95 | QFile outFile(fname); | 94 | QFile outFile(fname); | ||
96 | if (! outFile.open(QIODevice::WriteOnly)) { | 95 | if (! outFile.open(QIODevice::WriteOnly)) { | ||
97 | qCCritical(KDocToolsLog) << QStringLiteral("Could not write %1") | 96 | qCCritical(KDocToolsLog) << QStringLiteral("Could not write %1") | ||
98 | .arg(outFile.fileName()); | 97 | .arg(outFile.fileName()); | ||
99 | return (1); | 98 | return (1); | ||
100 | } | 99 | } | ||
101 | 100 | | |||
102 | QTextStream outStream(&outFile); | 101 | QTextStream outStream(&outFile); | ||
103 | outStream << "<?xml version='1.0'?>" << endl; | 102 | outStream << "<?xml version='1.0'?>\n"; | ||
104 | outStream << QStringLiteral("<!DOCTYPE l:i18n SYSTEM \"%1\">") | 103 | outStream << QStringLiteral("<!DOCTYPE l:i18n SYSTEM \"%1\">") | ||
105 | .arg(dtdPath) << endl; | 104 | .arg(dtdPath) << QLatin1Char('\n'); | ||
106 | 105 | | |||
107 | if (!langMap.isEmpty()) { | 106 | if (!langMap.isEmpty()) { | ||
108 | outStream | 107 | outStream | ||
109 | << "<l:i18n xmlns:l=\"http://docbook.sourceforge.net/xmlns/l10n/1.0\">" | 108 | << "<l:i18n xmlns:l=\"http://docbook.sourceforge.net/xmlns/l10n/1.0\">" | ||
110 | << endl; | 109 | << QLatin1Char('\n'); | ||
111 | LangListType::const_iterator i = langMap.constBegin(); | 110 | LangListType::const_iterator i = langMap.constBegin(); | ||
112 | while (i != langMap.constEnd()) { | 111 | while (i != langMap.constEnd()) { | ||
113 | outStream << QStringLiteral("<l:l10n language=\"%1\" href=\"%2\"/>") | 112 | outStream << QStringLiteral("<l:l10n language=\"%1\" href=\"%2\"/>") | ||
114 | .arg((*i).first).arg((*i).second) << endl; | 113 | .arg((*i).first).arg((*i).second) << QLatin1Char('\n'); | ||
115 | ++i; | 114 | ++i; | ||
116 | } | 115 | } | ||
117 | outStream << "</l:i18n>" << endl; | 116 | outStream << "</l:i18n>\n"; | ||
118 | } | 117 | } | ||
119 | 118 | | |||
120 | outFile.close(); | 119 | outFile.close(); | ||
121 | 120 | | |||
122 | return (0); | 121 | return (0); | ||
123 | } | 122 | } | ||
124 | 123 | | |||
125 | inline const QString addTrailingSlash(const QString &p) | 124 | inline const QString addTrailingSlash(const QString &p) | ||
▲ Show 20 Lines • Show All 131 Lines • Show Last 20 Lines |