feat(route): Add multi-language support for RFI. (#13147)

* feat(route): Add multi-language support for RFI.

* Update doc.

* Update multimedia.md

* Update multimedia.md

* Update multimedia.md

* Update website/docs/routes/multimedia.md

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update news.js

* Update multimedia.md

* Update multimedia.md

* Update news.js

---------
This commit is contained in:
Andvari 2023-09-03 01:59:33 +08:00 committed by GitHub
parent c4c947d237
commit bd9c3afcc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 5 deletions

View File

@ -1,3 +1,3 @@
module.exports = {
'/news': ['nczitzk'],
'/news/:lang?': ['nczitzk'],
};

View File

@ -3,8 +3,14 @@ const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const LANGUAGE = new Map([
['en', '/en/live-news/'],
['fr', '/fr/en-bref/'],
['cn', '/cn/滚动新闻'],
]);
const rootUrl = 'https://www.rfi.fr';
const currentUrl = `${rootUrl}/cn/滚动新闻`;
const currentUrl = `${rootUrl}${LANGUAGE.get(ctx.params.lang ?? 'cn')}`;
const response = await got({
method: 'get',
url: currentUrl,
@ -42,8 +48,9 @@ module.exports = async (ctx) => {
);
ctx.state.data = {
title: '滚动新闻 - 法国国际广播电台',
title: $('title').text(),
link: currentUrl,
item: items,
language: $("meta[property='og:locale']").attr('content'),
};
};

View File

@ -1,3 +1,3 @@
module.exports = function (router) {
router.get('/news', require('./news'));
router.get('/news/:lang?', require('./news'));
};

View File

@ -1551,7 +1551,15 @@ When `mediaType` is `movie`, `sheet` should be:
### 滚动新闻 {#fa-guo-guo-ji-guang-bo-dian-tai-gun-dong-xin-wen}
<Route author="nczitzk" example="/rfi/news" path="/rfi/news"/>
<Route author="nczitzk" example="/rfi/news" path="/rfi/news/:lang?" paramsDesc={['语言默认为cn']}>
**lang**
| en | cn | fr |
| --- | --- | --- |
| 英文 | 中文 | 法文 |
</Route>
## 高清电台 {#gao-qing-dian-tai}