mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
Document folder structure to encourage translation in various languages (#1170)
* Restructuring docs resource folder Signed-off-by: Hiroshi Miura <miurahr@linux.com> * Correct variable name according to coding rule Signed-off-by: Hiroshi Miura <miurahr@linux.com>
This commit is contained in:
parent
da2d41309a
commit
35080bd175
@ -1479,28 +1479,20 @@ QWebEngineView *VUtils::getWebEngineView(const QColor &p_background, QWidget *p_
|
|||||||
return viewer;
|
return viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VUtils::getFileNameWithLocale(const QString &p_name, const QString &p_locale)
|
|
||||||
{
|
|
||||||
QString locale = p_locale.isEmpty() ? getLocale() : p_locale;
|
|
||||||
locale = locale.split('_')[0];
|
|
||||||
|
|
||||||
QFileInfo fi(p_name);
|
|
||||||
QString baseName = fi.completeBaseName();
|
|
||||||
QString suffix = fi.suffix();
|
|
||||||
|
|
||||||
if (suffix.isEmpty()) {
|
|
||||||
return QString("%1_%2").arg(baseName).arg(locale);
|
|
||||||
} else {
|
|
||||||
return QString("%1_%2.%3").arg(baseName).arg(locale).arg(suffix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString VUtils::getDocFile(const QString &p_name)
|
QString VUtils::getDocFile(const QString &p_name)
|
||||||
{
|
{
|
||||||
QDir dir(VNote::c_docFileFolder);
|
QDir dir(VNote::c_docFileFolder);
|
||||||
QString name(getFileNameWithLocale(p_name));
|
QString fullLocale = getLocale();
|
||||||
|
QString shortLocale = fullLocale.split('_')[0];
|
||||||
|
// First looks full locale name folder (eg. zh_CN)
|
||||||
|
QString name = QString("%1/%2").arg(fullLocale).arg(p_name);
|
||||||
if (!dir.exists(name)) {
|
if (!dir.exists(name)) {
|
||||||
name = getFileNameWithLocale(p_name, "en_US");
|
// If not found, try 2-char locale name folder (eg. ja)
|
||||||
|
name = QString("%1/%2").arg(shortLocale).arg(p_name);
|
||||||
|
}
|
||||||
|
if (!dir.exists(name)) {
|
||||||
|
// even not found, fall back to default english folder.
|
||||||
|
name = QString("%1/%2").arg("en").arg(p_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir.filePath(name);
|
return dir.filePath(name);
|
||||||
|
@ -318,11 +318,6 @@ public:
|
|||||||
|
|
||||||
static void setDynamicProperty(QWidget *p_widget, const char *p_prop, bool p_val = true);
|
static void setDynamicProperty(QWidget *p_widget, const char *p_prop, bool p_val = true);
|
||||||
|
|
||||||
// Return a file name with locale @p_locale.
|
|
||||||
// If @p_locale is empty, use system's locale instead.
|
|
||||||
static QString getFileNameWithLocale(const QString &p_name,
|
|
||||||
const QString &p_locale = QString());
|
|
||||||
|
|
||||||
// Return a doc file path.
|
// Return a doc file path.
|
||||||
static QString getDocFile(const QString &p_name);
|
static QString getDocFile(const QString &p_name);
|
||||||
|
|
||||||
|
@ -57,9 +57,6 @@
|
|||||||
<file>utils/markdown-it/markdown-it-headinganchor.js</file>
|
<file>utils/markdown-it/markdown-it-headinganchor.js</file>
|
||||||
<file>utils/markdown-it/markdown-it-task-lists.min.js</file>
|
<file>utils/markdown-it/markdown-it-task-lists.min.js</file>
|
||||||
<file>resources/icons/close_red.svg</file>
|
<file>resources/icons/close_red.svg</file>
|
||||||
<file>resources/docs/shortcuts_en.md</file>
|
|
||||||
<file>resources/docs/shortcuts_zh.md</file>
|
|
||||||
<file>resources/docs/shortcuts_ja.md</file>
|
|
||||||
<file>utils/showdown/showdown.min.js</file>
|
<file>utils/showdown/showdown.min.js</file>
|
||||||
<file>resources/showdown.js</file>
|
<file>resources/showdown.js</file>
|
||||||
<file>utils/showdown/showdown-headinganchor.js</file>
|
<file>utils/showdown/showdown-headinganchor.js</file>
|
||||||
@ -76,9 +73,6 @@
|
|||||||
<file>resources/icons/inline_code.svg</file>
|
<file>resources/icons/inline_code.svg</file>
|
||||||
<file>resources/icons/close_note_tb.svg</file>
|
<file>resources/icons/close_note_tb.svg</file>
|
||||||
<file>resources/icons/editing_modified.svg</file>
|
<file>resources/icons/editing_modified.svg</file>
|
||||||
<file>resources/docs/markdown_guide_en.md</file>
|
|
||||||
<file>resources/docs/markdown_guide_zh.md</file>
|
|
||||||
<file>resources/docs/markdown_guide_ja.md</file>
|
|
||||||
<file>utils/highlightjs/highlightjs-line-numbers.min.js</file>
|
<file>utils/highlightjs/highlightjs-line-numbers.min.js</file>
|
||||||
<file>resources/icons/recycle_bin.svg</file>
|
<file>resources/icons/recycle_bin.svg</file>
|
||||||
<file>resources/icons/empty_recycle_bin.svg</file>
|
<file>resources/icons/empty_recycle_bin.svg</file>
|
||||||
@ -157,20 +151,8 @@
|
|||||||
<file>resources/themes/v_moonlight/v_moonlight_codeblock.css</file>
|
<file>resources/themes/v_moonlight/v_moonlight_codeblock.css</file>
|
||||||
<file>resources/simple_template.html</file>
|
<file>resources/simple_template.html</file>
|
||||||
<file>resources/typewriter.css</file>
|
<file>resources/typewriter.css</file>
|
||||||
<file>resources/docs/tips_custom_shortcut_en.md</file>
|
|
||||||
<file>resources/docs/tips_custom_shortcut_zh.md</file>
|
|
||||||
<file>resources/docs/tips_custom_shortcut_ja.md</file>
|
|
||||||
<file>resources/icons/add_style.svg</file>
|
<file>resources/icons/add_style.svg</file>
|
||||||
<file>resources/docs/tips_add_theme_en.md</file>
|
|
||||||
<file>resources/docs/tips_add_theme_zh.md</file>
|
|
||||||
<file>resources/docs/tips_add_theme_ja.md</file>
|
|
||||||
<file>resources/docs/tips_add_style_en.md</file>
|
|
||||||
<file>resources/docs/tips_add_style_zh.md</file>
|
|
||||||
<file>resources/docs/tips_add_style_ja.md</file>
|
|
||||||
<file>resources/icons/add_program.svg</file>
|
<file>resources/icons/add_program.svg</file>
|
||||||
<file>resources/docs/tips_external_program_en.md</file>
|
|
||||||
<file>resources/docs/tips_external_program_zh.md</file>
|
|
||||||
<file>resources/docs/tips_external_program_ja.md</file>
|
|
||||||
<file>translations/widgets_zh_CN.qm</file>
|
<file>translations/widgets_zh_CN.qm</file>
|
||||||
<file>translations/qdialogbuttonbox_zh_CN.qm</file>
|
<file>translations/qdialogbuttonbox_zh_CN.qm</file>
|
||||||
<file>translations/qwebengine_zh_CN.qm</file>
|
<file>translations/qwebengine_zh_CN.qm</file>
|
||||||
@ -278,9 +260,6 @@
|
|||||||
<file>resources/export/outline.js</file>
|
<file>resources/export/outline.js</file>
|
||||||
<file>resources/icons/add.svg</file>
|
<file>resources/icons/add.svg</file>
|
||||||
<file>resources/icons/delete.svg</file>
|
<file>resources/icons/delete.svg</file>
|
||||||
<file>resources/docs/welcome_en.md</file>
|
|
||||||
<file>resources/docs/welcome_zh.md</file>
|
|
||||||
<file>resources/docs/welcome_ja.md</file>
|
|
||||||
<file>resources/icons/256x256/vnote.png</file>
|
<file>resources/icons/256x256/vnote.png</file>
|
||||||
<file>utils/markdown-it/markdown-it-container.min.js</file>
|
<file>utils/markdown-it/markdown-it-container.min.js</file>
|
||||||
<file>resources/icons/table.svg</file>
|
<file>resources/icons/table.svg</file>
|
||||||
@ -358,5 +337,26 @@
|
|||||||
<file>resources/themes/v_next/v_next_codeblock.css</file>
|
<file>resources/themes/v_next/v_next_codeblock.css</file>
|
||||||
<file>resources/themes/v_next/v_next_mermaid.css</file>
|
<file>resources/themes/v_next/v_next_mermaid.css</file>
|
||||||
<file>utils/mermaid/mermaid.min.js</file>
|
<file>utils/mermaid/mermaid.min.js</file>
|
||||||
|
<file>resources/docs/en/markdown_guide.md</file>
|
||||||
|
<file>resources/docs/en/shortcuts.md</file>
|
||||||
|
<file>resources/docs/en/tips_add_style.md</file>
|
||||||
|
<file>resources/docs/en/tips_add_theme.md</file>
|
||||||
|
<file>resources/docs/en/tips_custom_shortcut.md</file>
|
||||||
|
<file>resources/docs/en/tips_external_program.md</file>
|
||||||
|
<file>resources/docs/en/welcome.md</file>
|
||||||
|
<file>resources/docs/ja/markdown_guide.md</file>
|
||||||
|
<file>resources/docs/ja/shortcuts.md</file>
|
||||||
|
<file>resources/docs/ja/tips_add_style.md</file>
|
||||||
|
<file>resources/docs/ja/tips_add_theme.md</file>
|
||||||
|
<file>resources/docs/ja/tips_custom_shortcut.md</file>
|
||||||
|
<file>resources/docs/ja/tips_external_program.md</file>
|
||||||
|
<file>resources/docs/ja/welcome.md</file>
|
||||||
|
<file>resources/docs/zh_CN/markdown_guide.md</file>
|
||||||
|
<file>resources/docs/zh_CN/shortcuts.md</file>
|
||||||
|
<file>resources/docs/zh_CN/tips_add_style.md</file>
|
||||||
|
<file>resources/docs/zh_CN/tips_add_theme.md</file>
|
||||||
|
<file>resources/docs/zh_CN/tips_custom_shortcut.md</file>
|
||||||
|
<file>resources/docs/zh_CN/tips_external_program.md</file>
|
||||||
|
<file>resources/docs/zh_CN/welcome.md</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user