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:
parent
c4c947d237
commit
bd9c3afcc5
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = {
|
||||
'/news': ['nczitzk'],
|
||||
'/news/:lang?': ['nczitzk'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/news', require('./news'));
|
||||
router.get('/news/:lang?', require('./news'));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue