diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 0068aa4..12fbac1 100755 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -13,6 +13,10 @@ module.exports = { favicon: 'img/favicon.ico', organizationName: user, // Usually your GitHub org/user name. projectName: project, // Usually your repo name. + i18n: { + defaultLocale: 'en', + locales: ['en', 'zh-Hant'], + }, themeConfig: { prism: { additionalLanguages: ["php"] @@ -24,7 +28,11 @@ module.exports = { src: 'img/logo.svg', }, items: [ - {to: 'docs/getting-started', label: 'Docs', position: 'left'}, + {to: 'docs/getting-started', label: 'Docs', position: 'left'}, + { + type: 'localeDropdown', + position: 'left', + }, { href: githubUrl, label: 'GitHub', diff --git a/docs/i18n/zh-Hant/code.json b/docs/i18n/zh-Hant/code.json new file mode 100644 index 0000000..afd4b00 --- /dev/null +++ b/docs/i18n/zh-Hant/code.json @@ -0,0 +1,309 @@ +{ + "theme.ErrorPageContent.title": { + "message": "此頁已當機。", + "description": "The title of the fallback page when the page crashed" + }, + "theme.blog.archive.title": { + "message": "歷史文章", + "description": "The page & hero title of the blog archive page" + }, + "theme.blog.archive.description": { + "message": "歷史文章", + "description": "The page & hero description of the blog archive page" + }, + "theme.BackToTopButton.buttonAriaLabel": { + "message": "回到頂部", + "description": "The ARIA label for the back to top button" + }, + "theme.blog.paginator.navAriaLabel": { + "message": "部落格文章列表分頁導覽", + "description": "The ARIA label for the blog pagination" + }, + "theme.blog.paginator.newerEntries": { + "message": "較新的文章", + "description": "The label used to navigate to the newer blog posts page (previous page)" + }, + "theme.blog.paginator.olderEntries": { + "message": "較舊的文章", + "description": "The label used to navigate to the older blog posts page (next page)" + }, + "theme.blog.post.paginator.navAriaLabel": { + "message": "部落格文章分頁導覽", + "description": "The ARIA label for the blog posts pagination" + }, + "theme.blog.post.paginator.newerPost": { + "message": "較新一篇", + "description": "The blog post button label to navigate to the newer/previous post" + }, + "theme.blog.post.paginator.olderPost": { + "message": "較舊一篇", + "description": "The blog post button label to navigate to the older/next post" + }, + "theme.blog.post.plurals": { + "message": "{count} 篇文章", + "description": "Pluralized label for \"{count} posts\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" + }, + "theme.blog.tagTitle": { + "message": "{nPosts} 含有標籤「{tagName}」", + "description": "The title of the page for a blog tag" + }, + "theme.tags.tagsPageLink": { + "message": "檢視所有標籤", + "description": "The label of the link targeting the tag list page" + }, + "theme.colorToggle.ariaLabel": { + "message": "切換淺色/暗黑模式(當前為{mode})", + "description": "The ARIA label for the navbar color mode toggle" + }, + "theme.colorToggle.ariaLabel.mode.dark": { + "message": "暗黑模式", + "description": "The name for the dark color mode" + }, + "theme.colorToggle.ariaLabel.mode.light": { + "message": "淺色模式", + "description": "The name for the light color mode" + }, + "theme.docs.breadcrumbs.navAriaLabel": { + "message": "頁面路徑", + "description": "The ARIA label for the breadcrumbs" + }, + "theme.docs.DocCard.categoryDescription.plurals": { + "message": "{count} 個項目", + "description": "The default description for a category card in the generated index about how many items this category includes" + }, + "theme.docs.paginator.navAriaLabel": { + "message": "文件選項卡", + "description": "The ARIA label for the docs pagination" + }, + "theme.docs.paginator.previous": { + "message": "上一頁", + "description": "The label used to navigate to the previous doc" + }, + "theme.docs.paginator.next": { + "message": "下一頁", + "description": "The label used to navigate to the next doc" + }, + "theme.docs.tagDocListPageTitle.nDocsTagged": { + "message": "{count} 篇文件帶有標籤", + "description": "Pluralized label for \"{count} docs tagged\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" + }, + "theme.docs.tagDocListPageTitle": { + "message": "{nDocsTagged}「{tagName}」", + "description": "The title of the page for a docs tag" + }, + "theme.docs.versionBadge.label": { + "message": "版本:{versionLabel}" + }, + "theme.docs.versions.unreleasedVersionLabel": { + "message": "此為 {siteTitle} {versionLabel} 版尚未發行的文件。", + "description": "The label used to tell the user that he's browsing an unreleased doc version" + }, + "theme.docs.versions.unmaintainedVersionLabel": { + "message": "此為 {siteTitle} {versionLabel} 版的文件,現已不再積極維護。", + "description": "The label used to tell the user that he's browsing an unmaintained doc version" + }, + "theme.docs.versions.latestVersionSuggestionLabel": { + "message": "最新的文件請參閱 {latestVersionLink} ({versionLabel})。", + "description": "The label used to tell the user to check the latest version" + }, + "theme.docs.versions.latestVersionLinkLabel": { + "message": "最新版本", + "description": "The label used for the latest version suggestion link label" + }, + "theme.common.editThisPage": { + "message": "編輯此頁", + "description": "The link label to edit the current page" + }, + "theme.common.headingLinkTitle": { + "message": "{heading}的直接連結", + "description": "Title for link to heading" + }, + "theme.lastUpdated.atDate": { + "message": "於 {date} ", + "description": "The words used to describe on which date a page has been last updated" + }, + "theme.lastUpdated.byUser": { + "message": "由 {user} ", + "description": "The words used to describe by who the page has been last updated" + }, + "theme.lastUpdated.lastUpdatedAtBy": { + "message": "最後{byUser}{atDate}更新", + "description": "The sentence used to display when a page has been last updated, and by who" + }, + "theme.navbar.mobileVersionsDropdown.label": { + "message": "選擇版本", + "description": "The label for the navbar versions dropdown on mobile view" + }, + "theme.NotFound.title": { + "message": "找不到頁面", + "description": "The title of the 404 page" + }, + "theme.tags.tagsListLabel": { + "message": "標籤:", + "description": "The label alongside a tag list" + }, + "theme.admonition.caution": { + "message": "警告", + "description": "The default label used for the Caution admonition (:::caution)" + }, + "theme.admonition.danger": { + "message": "危險", + "description": "The default label used for the Danger admonition (:::danger)" + }, + "theme.admonition.info": { + "message": "信息", + "description": "The default label used for the Info admonition (:::info)" + }, + "theme.admonition.note": { + "message": "備註", + "description": "The default label used for the Note admonition (:::note)" + }, + "theme.admonition.tip": { + "message": "提示", + "description": "The default label used for the Tip admonition (:::tip)" + }, + "theme.admonition.warning": { + "message": "warning", + "description": "The default label used for the Warning admonition (:::warning)" + }, + "theme.AnnouncementBar.closeButtonAriaLabel": { + "message": "關閉", + "description": "The ARIA label for close button of announcement bar" + }, + "theme.blog.sidebar.navAriaLabel": { + "message": "最近部落格文章導覽", + "description": "The ARIA label for recent posts in the blog sidebar" + }, + "theme.CodeBlock.copied": { + "message": "複製成功", + "description": "The copied button label on code blocks" + }, + "theme.CodeBlock.copyButtonAriaLabel": { + "message": "複製代碼至剪貼簿", + "description": "The ARIA label for copy code blocks button" + }, + "theme.CodeBlock.copy": { + "message": "複製", + "description": "The copy button label on code blocks" + }, + "theme.CodeBlock.wordWrapToggle": { + "message": "切換自動換行", + "description": "The title attribute for toggle word wrapping button of code block lines" + }, + "theme.DocSidebarItem.expandCategoryAriaLabel": { + "message": "Expand sidebar category '{label}'", + "description": "The ARIA label to expand the sidebar category" + }, + "theme.DocSidebarItem.collapseCategoryAriaLabel": { + "message": "Collapse sidebar category '{label}'", + "description": "The ARIA label to collapse the sidebar category" + }, + "theme.NavBar.navAriaLabel": { + "message": "主導航", + "description": "The ARIA label for the main navigation" + }, + "theme.navbar.mobileLanguageDropdown.label": { + "message": "選擇語言", + "description": "The label for the mobile language switcher dropdown" + }, + "theme.NotFound.p1": { + "message": "我們沒有您要找的頁面。", + "description": "The first paragraph of the 404 page" + }, + "theme.NotFound.p2": { + "message": "請聯絡原始連結來源網站的所有者,並通知他們連結已毀損。", + "description": "The 2nd paragraph of the 404 page" + }, + "theme.TOCCollapsible.toggleButtonLabel": { + "message": "本頁導覽", + "description": "The label used by the button on the collapsible TOC component" + }, + "theme.blog.post.readMore": { + "message": "閱讀更多", + "description": "The label used in blog post item excerpts to link to full blog posts" + }, + "theme.blog.post.readMoreLabel": { + "message": "閱讀 {title} 全文", + "description": "The ARIA label for the link to full blog posts from excerpts" + }, + "theme.blog.post.readingTime.plurals": { + "message": "閱讀時間約 {readingTime} 分鐘", + "description": "Pluralized label for \"{readingTime} min read\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" + }, + "theme.docs.breadcrumbs.home": { + "message": "主頁面", + "description": "The ARIA label for the home page in the breadcrumbs" + }, + "theme.docs.sidebar.collapseButtonTitle": { + "message": "收起側邊欄", + "description": "The title attribute for collapse button of doc sidebar" + }, + "theme.docs.sidebar.collapseButtonAriaLabel": { + "message": "收起側邊欄", + "description": "The title attribute for collapse button of doc sidebar" + }, + "theme.docs.sidebar.navAriaLabel": { + "message": "文件側邊欄", + "description": "The ARIA label for the sidebar navigation" + }, + "theme.docs.sidebar.closeSidebarButtonAriaLabel": { + "message": "Close navigation bar", + "description": "The ARIA label for close button of mobile sidebar" + }, + "theme.docs.sidebar.toggleSidebarButtonAriaLabel": { + "message": "Toggle navigation bar", + "description": "The ARIA label for hamburger menu button of mobile navigation" + }, + "theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": { + "message": "← 回到主選單", + "description": "The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)" + }, + "theme.docs.sidebar.expandButtonTitle": { + "message": "展開側邊欄", + "description": "The ARIA label and title attribute for expand button of doc sidebar" + }, + "theme.docs.sidebar.expandButtonAriaLabel": { + "message": "展開側邊欄", + "description": "The ARIA label and title attribute for expand button of doc sidebar" + }, + "cmfcmf/d-s-l.searchBar.placeholder": { + "message": "搜索...", + "description": "Placeholder shown in the searchbar" + }, + "cmfcmf/d-s-l.searchBar.clearButtonTitle": { + "message": "清除", + "description": "Title of the button to clear the current search input" + }, + "cmfcmf/d-s-l.searchBar.detachedCancelButtonText": { + "message": "取消", + "description": "Text of the button to close the detached search window" + }, + "cmfcmf/d-s-l.searchBar.submitButtonTitle": { + "message": "搜索", + "description": "Title of the button to submit a new search" + }, + "cmfcmf/d-s-l.searchBar.noResults": { + "message": "无搜索结果", + "description": "message shown if no results are found" + }, + "theme.ErrorPageContent.tryAgain": { + "message": "重試", + "description": "The label of the button to try again rendering when the React error boundary captures an error" + }, + "theme.common.skipToMainContent": { + "message": "跳至主要内容", + "description": "The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation" + }, + "theme.tags.tagsPageTitle": { + "message": "標籤", + "description": "The title of the tag list page" + }, + "theme.unlistedContent.title": { + "message": "未列出頁", + "description": "The unlisted content banner title" + }, + "theme.unlistedContent.message": { + "message": "此頁面未列出。搜索引擎不會對其索引,只有擁有直接連結的用戶才能訪問。", + "description": "The unlisted content banner message" + } +} diff --git a/docs/i18n/zh-Hant/docusaurus-plugin-content-blog/options.json b/docs/i18n/zh-Hant/docusaurus-plugin-content-blog/options.json new file mode 100644 index 0000000..cf655cb --- /dev/null +++ b/docs/i18n/zh-Hant/docusaurus-plugin-content-blog/options.json @@ -0,0 +1,14 @@ +{ + "title": { + "message": "部落格", + "description": "The title for the blog used in SEO" + }, + "description": { + "message": "部落格", + "description": "The description for the blog used in SEO" + }, + "sidebar.title": { + "message": "最新文章", + "description": "The label for the left sidebar" + } +} diff --git a/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current.json b/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current.json new file mode 100644 index 0000000..12eab05 --- /dev/null +++ b/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current.json @@ -0,0 +1,10 @@ +{ + "version.label": { + "message": "當前版本", + "description": "The label for version current" + }, + "sidebar.someSidebar.category.APIs": { + "message": "APIs", + "description": "The label for category APIs in sidebar someSidebar" + } +} diff --git a/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current/api-key.md b/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current/api-key.md new file mode 100644 index 0000000..4c5ad41 --- /dev/null +++ b/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current/api-key.md @@ -0,0 +1,15 @@ +--- +title: API 金鑰 +--- + +所有請求都需要從 OpenWeatherMap 獲取的免費 API 金鑰(有時稱為 "APPID")。 +要獲取您的 API 金鑰,請[註冊 OpenWeatherMap 帳戶](https://home.openweathermap.org/users/sign_up)。 + +在您收到 API 金鑰後,**可能需要 ["幾個小時"](https://openweathermap.org/appid) 才能激活!其他用戶[報告](https://github.com/cmfcmf/OpenWeatherMap-PHP-API/issues/46) 大約需要 10 分鐘** 才能使 API 金鑰生效。 + +請注意 OpenWeatherMap 提供數據的許可證。撰寫本文時,所有數據均按照 **CC BY-SA 4.0** 授權,即使是付費帳戶也是如此。然而,請記住,本項目與 OpenWeatherMap 無關,這些信息可能已過時,且我無法給您法律建議。請務必自行查看條款和條件: + +- https://openweathermap.org/terms +- https://openweathermap.org/price + +*如果您的 API 金鑰或帳戶存在問題,請[直接聯繫 OpenWeatherMap](https://openweathermap.force.com/s/contactsupport) 而不是提交問題,因為我很可能無法幫助您解決帳戶問題。* \ No newline at end of file diff --git a/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current/apis/air-pollution.md b/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current/apis/air-pollution.md new file mode 100644 index 0000000..883084a --- /dev/null +++ b/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current/apis/air-pollution.md @@ -0,0 +1,80 @@ +--- +title: 空氣污染 API +sidebar_label: '空氣污染' +--- + +此 API 允許您檢索當前、預測和歷史的紫外線指數(UV 指數)。 + +> 對應的 OpenWeatherMap 文件: +> +> - [一氧化碳 (CO)](https://openweathermap.org/api/pollution/co) +> - [臭氧 (O3)](https://openweathermap.org/api/pollution/o3) +> - [二氧化氮 (NO2)](https://openweathermap.org/api/pollution/no2) +> - [二氧化硫 (SO2)](https://openweathermap.org/api/pollution/so2) + +## 用法 + +- `$type`:可以是 `"O3"`、`"NO2"`、`"SO2"` 或 `"CO"` 其中之一。 +- `$lat` / `$lng`:緯度和經度必須以字符串形式提供,因為小數點後的位數決定了搜索半徑。指定更多位數會導致更精確的結果,但位數過多可能導致無法獲取結果。 +- `$date`:要檢索數據的日期。`"current"` 請求最新可用的信息。您也可以以 ISO 8601 格式指定日期。更多信息請參見 [OpenWeatherMap 文件](https://openweathermap.org/api/pollution/co)。 + +```php +// $type = +$co = $owm->getAirPollution($type, $lat, $lng, $date = "current"); +``` + +返回值取決於 `$type`,在後續部分進行討論。 + +## 一氧化碳 (CO) + +```php +$co = $owm->getAirPollution("CO", "52", "13"); +if ($co === null) { + // 無可用數據 +} else { + foreach ($co->values as $data) { + echo $data["value"]; + echo $data["value"]->getPrecision(); + echo $data["pressure"]; + } +} +``` + +## 臭氧 (O3) + +```php +$o3 = $owm->getAirPollution("O3", "52", "13"); +if ($o3 === null) { + // 無可用數據 +} else { + echo $o3->value; +} +``` + +## 二氧化氮 (NO2) + +```php +$no2 = $owm->getAirPollution("NO2", "52", "13"); +if ($no2 === null) { + // 無可用數據 +} else { + echo $no2->value; + echo $no2->valueStratosphere; + echo $no2->valueTroposphere; +} +``` + +## 二氧化硫 (SO2) + +```php +$so2 = $owm->getAirPollution("SO2", "52", "13"); +if ($so2 === null) { + // 無可用數據 +} else { + foreach ($so2->values as $data) { + echo $data["value"]; + echo $data["value"]->getPrecision(); + echo $data["pressure"]; + } +} +``` \ No newline at end of file diff --git a/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current/apis/current-weather.md b/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current/apis/current-weather.md new file mode 100644 index 0000000..9e74ad9 --- /dev/null +++ b/docs/i18n/zh-Hant/docusaurus-plugin-content-docs/current/apis/current-weather.md @@ -0,0 +1,181 @@ +--- +title: 當前天氣 API +sidebar_label: '當前天氣' +--- + +此 API 允許您檢索當前的天氣數據。 + +> [對應的 OpenWeatherMap 文件](https://openweathermap.org/current) + +`$owm->getWeather()` 函式接受以下參數: + +| 名稱 | 類型 | 預設值 | 描述 | +|------|------|---------|-------------| +| `$query` | `mixed` | -- | 請參見下文 | +| `$units` | `"imperial"`|`"metric"` | `"imperial"` | 使用的單位 | +| `$lang` | `string` | `en` | 語言之一,請參見 [官方文件底部](https://openweathermap.org/current#multi) | + +## `$query` 參數 + +第一個參數確定要獲取天氣數據的位置。有多種函式可用: + +### 根據城市名稱 + +指定國家是可選的。 + +```php +$weather = $owm->getWeather('Berlin,DE', $units, $lang); +``` + +### 根據城市 ID + +單個城市 ID: +```php +$weather = $owm->getWeather(2172797, $units, $lang); +``` + +多個城市 ID: +```php +// 警告:這使用了一個不同的函式 (getWeatherGroup) +// 與其他查詢格式 (getWeather) 不同! +$weathers = $owm->getWeatherGroup([2172797, 2172798], $units, $lang); +foreach ($weathers as $weather) { + // 處理 +} +``` + +### 根據郵政編碼 + +指定國家是可選的。 + +```php +// 印度,海得拉巴 +$weather = $owm->getWeather('zip:500001,IN', $units, $lang); +``` + +### 根據座標 + +```php +$weather = $owm->getWeather(['lat' => 77.73038, 'lon' => 41.89604], + $units, $lang); +``` + +## `$weather` 對象 + +返回的對象是一個 `Cmfcmf\OpenWeatherMap\CurrentWeather` 實例。它提供以下數據: + +| 名稱 | 類型 | 描述 | +|------|------|-------------| +| `lastUpdate` | `\DateTimeInterface` | 數據的最後更新時間 | +| `temperature->now` | `Unit` | 注意:這應命名為 `temperature->avg`,僅為向後兼容而命名為 `temperature->now`!返回給定位置的當前平均溫度(例如,一個大城市可能有多個溫度測量站) | +| `temperature->min` | `Unit` | 給定位置的當前最低溫度 | +| `temperature->max` | `Unit` | 給定位置的當前最高溫度 | +| `pressure` | `Unit` | 氣壓 | +| `humidity` | `Unit` | 濕度 | +| `sun->rise` | `\DateTimeInterface` | 日出時間 | +| `sun->set` | `\DateTimeInterface` | 日落時間 | +| `wind->speed` | `Unit` | 風速 | +| `wind->direction` | `Unit` | 風向 | +| `clouds` | `Unit` | 雲量百分比 | +| `precipitation` | `Unit` | 最近的降水 | +| `weather->id` | `int` | 當前天氣現象 ID | +| `weather->description` | `string` | 當前天氣描述 | +| `weather->icon` | `string` | 當前天氣圖標名稱。使用 `weather->getIconUrl()` 獲取 OpenWeatherMap 圖標的 URL | +| `city->id` | `int` | 內部城市 ID | +| `city->name` | `string` | 城市名稱 | +| `city->country` | `string` | 城市國家代碼 | +| `city->timezone` | `\DateTimeZone`|`null` | 城市時區 | +| `city->lon` | `float` | 城市經度 | +| `city->lat` | `float` | 城市緯度 | + +## 獲取原始數據 + +### HTML + +您還可以請求以 HTML 頁面形式的數據: + +```php +$html = $owm->getRawWeatherData('Berlin', $units, $lang, null, 'html'); +``` + +結果: + +```html + + +
+ + + + + + + + +