From cec5779db6514195cc41e912078a48663281a8b5 Mon Sep 17 00:00:00 2001 From: xueweihan <595666367@qq.com> Date: Tue, 30 Jul 2024 16:31:28 +0800 Subject: [PATCH] perf: trans ranking pange --- public/locales/en/rank.json | 48 ++++++++ public/locales/zh/rank.json | 48 ++++++++ src/components/navbar/Navbar.tsx | 2 +- src/components/rankTable/RankTable.tsx | 59 +++++++--- src/components/report/Report.tsx | 32 +----- src/pages/report/db-engines.tsx | 98 ++++++++++------ src/pages/report/netcraft.tsx | 149 ++++++++++++++----------- src/pages/report/tiobe.tsx | 97 ++++++++++------ src/types/rank.ts | 3 +- 9 files changed, 366 insertions(+), 170 deletions(-) create mode 100644 public/locales/en/rank.json create mode 100644 public/locales/zh/rank.json diff --git a/public/locales/en/rank.json b/public/locales/en/rank.json new file mode 100644 index 00000000..b3730dc3 --- /dev/null +++ b/public/locales/en/rank.json @@ -0,0 +1,48 @@ +{ + "tiobe": { + "title": "Programming Language Ranking", + "nav": "{{month}} {{year}} Programming Language Ranking", + "p_text": "The TIOBE Programming Community Index is an indicator of the popularity of programming languages, created and maintained by TIOBE Software BV, established in October 2000 in Eindhoven, the Netherlands. The index is calculated based on the number of search engine results for queries containing the name of the language. It includes results from Google, Baidu, Wikipedia, and YouTube.", + "thead": { + "position": "Rank", + "name": "Language", + "rating": "Ratings", + "change": "Change", + "md_change": "📊", + "star": "🏅️Year" + } + }, + "db": { + "title": "Database Ranking", + "nav": "{{month}} {{year}} Database Ranking", + "p_text": "The DB-Engines Ranking ranks database management systems by popularity, covering over 380 databases, updated monthly. The ranking is based on various factors including search engine results for the database name, Google Trends, Stack Overflow, social networks, and job postings mentioning the database.", + "thead": { + "position": "Rank", + "name": "Database", + "rating": "Score", + "change": "Change", + "md_change": "📊", + "model": "Model" + } + }, + "netcraft": { + "title": "Web Server Ranking", + "nav": "{{month}} {{year}} Web Server Ranking", + "p_text": "The Netcraft Ranking is a monthly ranking of web servers published by Netcraft, an internet services company founded in 1995. It is a major reference for understanding global web server market share and rankings, often cited by major media like The Wall Street Journal and Slashdot.", + "thead": { + "position": "Rank", + "name": "Server", + "rating": "Share", + "change": "Change", + "md_change": "📊", + "total": "Total" + }, + "market_title": "Market Share Ranking", + "active_title": "Active Site Ranking", + "servers": { + "apache": "An open-source web server that can run on most computer operating systems. Widely used for its multi-platform support and security, making it one of the most popular web server software.", + "nginx": "A free, open-source, lightweight, high-performance web server developed by Igor Sysoev for Rambler.ru, the second most visited site in Russia.", + "openresty": "A web platform based on Nginx, using the LuaJIT engine to run Lua scripts, created by Yichun Zhang." + } + } +} diff --git a/public/locales/zh/rank.json b/public/locales/zh/rank.json new file mode 100644 index 00000000..67ae8e74 --- /dev/null +++ b/public/locales/zh/rank.json @@ -0,0 +1,48 @@ +{ + "tiobe": { + "title": "编程语言排名", + "nav": "{{year}} 年 {{month}} 月编程语言排行榜", + "p_text": "「TIOBE 编程社区指数」是一种衡量编程语言流行度的标准,由成立于 2000 年 10 月位于荷兰埃因霍温的 TIOBE Software BV 创建和维护。该指数是根据网络搜索引擎对含有该语言名称的查询结果的数量计算出来的。该指数涵盖了 Google、百度、维基百科和 YouTube 的搜索结果。", + "thead": { + "position": "排名", + "name": "编程语言", + "rating": "流行度", + "change": "对比上月", + "md_change": "趋势", + "star": "年度明星" + } + }, + "db": { + "title": "数据库排名", + "nav": "{{year}} 年 {{month}} 月数据库排行榜", + "p_text": "「DB-Engines 排名」是按流行程度对数据库管理系统进行排名,涵盖 380 多个数据库,每月更新一次。排名标准包括搜索数据库名称时的搜索引擎结果的数量、Google 趋势、Stack Overflow、社交网络和提及数据库的工作机会等数据,综合比较排名。", + "thead": { + "position": "排名", + "name": "数据库", + "rating": "分数", + "change": "对比上月", + "md_change": "趋势", + "model": "类型" + } + }, + "netcraft": { + "title": "Web 服务器排名", + "nav": "{{year}} 年 {{month}} 月 Web 服务器排行榜", + "p_text": "「Netcraft 排名」是一个始于 1995 年的互联网服务公司发布的 Web 服务器排名,每月更新一次。目前已成为人们了解全球网站的服务器市场份额和排名情况的主要参考依据,时常被华尔街杂志、Slashdot 等知名媒体引用。", + "thead": { + "position": "排名", + "name": "服务器", + "rating": "占比", + "change": "对比上月", + "md_change": "趋势", + "total": "总数" + }, + "market_title": "市场份额排名", + "active_title": "活跃网站排名", + "servers": { + "apache": "一个开放源码的网页服务器,可以在大多数计算机操作系统中运行。由于其多平台和安全性被广泛使用,是最流行的 Web服务器端软件之一。", + "nginx": "免费开源、轻量级、高性能 Web 服务器,由伊戈尔·赛索耶夫为俄罗斯访问量第二的 Rambler.ru 站点开发。", + "openresty": "一个基于 Nginx 的 Web 平台,可以使用其 LuaJIT 引擎运行 Lua 脚本,由章亦春创建。" + } + } +} diff --git a/src/components/navbar/Navbar.tsx b/src/components/navbar/Navbar.tsx index b83e83d7..ea17a46f 100644 --- a/src/components/navbar/Navbar.tsx +++ b/src/components/navbar/Navbar.tsx @@ -34,7 +34,7 @@ const Navbar = ({ middleText = '', endText }: Props) => { {endText} ) : ( -
+ )} diff --git a/src/components/rankTable/RankTable.tsx b/src/components/rankTable/RankTable.tsx index e5a838bf..0c1e2a32 100644 --- a/src/components/rankTable/RankTable.tsx +++ b/src/components/rankTable/RankTable.tsx @@ -9,7 +9,8 @@ type column = { key: string; title: string; width: number | string; - render: (row: any, index: number) => any; + percent?: boolean; + render: (row: any, showPercent?: boolean) => any; }; type TableProps = { @@ -17,6 +18,23 @@ type TableProps = { list: RankDataItem[]; }; +export const getMonthName = ( + month: number, + i18n_lang: string, + options: { format?: 'short' | 'long'; forceEnglish?: boolean } = {} +) => { + const { format = 'short', forceEnglish = false } = options; + const date = new Date(2023, month - 1, 1); + + if (forceEnglish) { + return i18n_lang === 'en' + ? date.toLocaleString('en', { month: 'long' }) + : month; + } + + return date.toLocaleString(i18n_lang, { month: format }); +}; + export const Table = ({ columns, list }: TableProps) => { return (
- 「DB-Engines 排名」
- 是按流行程度对数据库管理系统进行排名,涵盖 380
- 多个系统,每月更新一次。
- 排名标准包括搜索数据库名称时的搜索引擎结果的数量、Google
- 趋势、Stack
- Overflow、社交网络和提及数据库的工作机会等数据,综合比较排名。
+
- 「Netcraft」
- 是一家总部位于英国巴斯始于 1995 年的互联网服务公司。
- 该公司官网每月发布的调研数据报告 Web Server Survey 系列
- 每月更新一次,已成为当今人们了解全球网站的服务器市场份额和排名情况的主要参考依据,
- 时常被华尔街杂志、Slashdot 等知名媒体引用。{' '}
+
- 「TIOBE 编程社区指数」
- 是一种衡量编程语言流行度的标准,由成立于 2000 年 10
- 月位于荷兰埃因霍温的 TIOBE Software BV 创建和维护。
- 该指数是根据网络搜索引擎对含有该语言名称的查询结果的数量计算出来的。该指数涵盖了
- Google、百度、维基百科和 YouTube 的搜索结果。
+