From 7be5acfdaf4bfd4f65cd5d6eb6bad16f1dc1c9c0 Mon Sep 17 00:00:00 2001 From: "Evan W. Patton" Date: Wed, 13 May 2020 13:32:38 -0400 Subject: [PATCH] Allow tutorials to be localized Change-Id: I564c76c2fd058592a5ec7fb4eb551b63b0b04cc3 --- scripts/utils.js | 46 ++++++- yr/tutorials/markdown-tutorial.zh_cn.md | 155 ++++++++++++++++++++++++ 2 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 yr/tutorials/markdown-tutorial.zh_cn.md diff --git a/scripts/utils.js b/scripts/utils.js index 830841b9..d2d6f73e 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -1,3 +1,5 @@ +// -*- mode: javascript; js-indent-offset: 2; -*- + if (typeof bd=="undefined") { bd={}; } @@ -24,7 +26,7 @@ bd.util.ajaxPost = function(url,params,callback, callbackError){ } } http.send(params); -} +}; bd.util.ajaxGet = function(url, callback, callbackError){ var xmlhttp; @@ -46,7 +48,7 @@ bd.util.ajaxGet = function(url, callback, callbackError){ xmlhttp.open("GET",url,true); xmlhttp.send(); -} +}; bd.util.getURLParamValue = function(name){ @@ -59,4 +61,42 @@ bd.util.getURLParamValue = function(name){ } else { return results[1]; } -} +}; + +(function() { + if (window.location.search != "") { + var match = /[?&]locale=([^?&]*)/.exec(window.location.search); + if (match) { + var target = match[1].toLowerCase(); + var parts = window.location.pathname.split('.'); + if (parts.length == 2) { + if (target.indexOf('en') == 0) { + // Already at the English version + return; + } + parts.splice(1, 0, target); + } else if (parts.length == 3) { + if (parts[1] == target) { + // Already here + return; + } else if (target.indexOf('en') == 0) { + // English doesn't have a language tag in the name + parts.splice(1, 1); + } else { + parts[1] = match[1].toLowerCase(); + } + } else { + return; + } + var newpath = parts.join('.'); + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + window.location.pathname = newpath; + } + }; + xhr.open('HEAD', newpath); + xhr.send(); + } + } +})(); diff --git a/yr/tutorials/markdown-tutorial.zh_cn.md b/yr/tutorials/markdown-tutorial.zh_cn.md new file mode 100644 index 00000000..e3cae0ee --- /dev/null +++ b/yr/tutorials/markdown-tutorial.zh_cn.md @@ -0,0 +1,155 @@ +--- +title: App Inventor教程创作 +layout: tutorial +--- + +# App Inventor教程创作 + +## 介绍 + +您可以使用Markdown编写App Inventor教程。 本文档简要介绍了如何使用Markdown创建教程。 + +## 创建标题 + +手风琴由1级标题组成。 您可以通过两种不同的方式进行指示: + +```markdown +# 标头 +``` + +要么 + +```markdown +标头 +=== +``` + +## 创建教程页面 + +通过在1级标题下创建2级标题来添加教程页面: + +```markdown +# 标头 + +## 第1页标题 + +第1页内容 + +## 第2页标题 + +第2页内容 +``` + +如果您喜欢标题的下划线方法,则可以使用`-`: + +```markdown +标头 +=== + +第1页标题 +--- + +第1页内容 + +第2页标题 +--- + +第2页内容 +``` + +## 添加方法 + +对于包含有关连接随播广告的信息的教程,您可以使用此技术添加操作方法: + +```markdown +# 连接到应用 + + +``` + +## 添加提示 + +您可以使用以下技术向本教程添加提示: + +```markdown + + +提示内容 + + +``` + +您还可以嵌套提示: + +```markdown + + +提示内容 + + + +解决方案内容 + + + + +``` + +## 有序列表 + +有序列表是使用数字创建的: + +```markdown +1. 项目1 +2. 项目2 +3. 项目3 +``` + +如果您需要更多高级功能(例如起始值),则还可以使用HTML: + +```markdown +
    +
  1. 项目4
  2. +
  3. 项目5
  4. +
+``` + +## 无序列表 + +通过使用某些符号(如项目符号)来使用无序列表: + +```markdown +* 第一 +* 第二 +* 第三 +``` + +您还可以嵌套列表: + +```markdown +* 第一 + * 子项目 + * 子项目 + * 子项目 +* 第二 +``` + +## 链接和图片 + +通过将链接的文本放在方括号 `[]` 中并将链接目标放在括号 `()` 中来创建链接: + +```markdown +[转到App Inventor](http://ai2.appinventor.mit.edu) +``` + +要创建图像,请使用链接语法并将感叹号(!)放在前面: + +```markdown +![辅助功能的替代文字)(http://link/to/image.png) +``` + +如果要制作图像以便放大图像,请在图像包含文本的末尾添加 `{:.enlargeImage}`。 + +```markdown +![大形象](image.png){:.enlargeImage} +```