Skip to content

Commit

Permalink
feat: add Chinese documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
Done-0 committed Jan 13, 2025
1 parent 5106fae commit d0c62b1
Show file tree
Hide file tree
Showing 100 changed files with 854 additions and 779 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/release-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,23 @@ jobs:
name: Install build wheel
with:
arch: ${{ matrix.target }}
distro: ubuntu20.04
distro: ubuntu22.04
githubToken: ${{ github.token }}
# Mount the dist directory as /artifacts in the container
dockerRunArgs: |
--volume "${PWD}/dist:/artifacts"
install: |
apt update -y
apt install -y gcc musl-dev python3-dev # this is needed for psutil
apt install -y --no-install-recommends software-properties-common
add-apt-repository ppa:deadsnakes/ppa
apt install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt update -y
PYTHON=python${{ matrix.python.version }}
apt install -y $PYTHON $PYTHON-distutils $PYTHON-venv
apt install -y gcc musl-dev python3-dev python${{ matrix.python.version }} python${{ matrix.python.version }}-venv
run: |
ls -lrth /artifacts
PYTHON=python${{ matrix.python.version }}
$PYTHON --version
$PYTHON -m venv venv
python${{ matrix.python.version }} -m venv venv
source venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install --force-reinstall dist/robyn*.whl
python -m pip install --upgrade pip setuptools wheel
python -m pip install --force-reinstall /artifacts/robyn*.whl
cd ~ && python -c 'import robyn'
- name: Upload wheels
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "robyn"
version = "0.64.2"
version = "0.65.0"
authors = ["Sanskar Jethi <[email protected]>"]
edition = "2021"
description = "Robyn is a Super Fast Async Python Web Framework with a Rust runtime."
Expand Down
14 changes: 14 additions & 0 deletions docs_src/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ const nextConfig = {
experimental: {
scrollRestoration: true,
},
i18n: {
locales: ['en', 'zh'],
defaultLocale: 'en',
localeDetection: false,
},
async redirects() {
return [
{
source: '/documentation',
destination: '/documentation/en',
permanent: false,
},
]
},
}

export default withMDX(nextConfig)
8 changes: 0 additions & 8 deletions docs_src/src/components/documentation/ApiDocs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ const guides = [
name: 'Websockets',
description: 'Learn how to use Websockets in Robyn.',
},
{
href: '/documentation/api_reference/views',
name: 'Code Organisation',
description: 'Learn about Views and SubRouters in Robyn.',
},

{
href: '/documentation/api_reference/exceptions',
name: 'Exceptions',
Expand All @@ -94,8 +88,6 @@ const guides = [
name: 'Multiprocess Execution',
description: 'Learn about the behaviour or variables during multithreading',
},


{
href: '/documentation/api_reference/using_rust_directly',
name: 'Direct Rust Usage',
Expand Down
72 changes: 72 additions & 0 deletions docs_src/src/components/documentation/LanguageSelector.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { useRouter } from 'next/router'
import { Menu } from '@headlessui/react'
import { motion } from 'framer-motion'

const languages = [
{ code: 'en', name: 'English' },
{ code: 'zh', name: '中文' },
]

function LanguageSelector() {
const router = useRouter()
const { pathname, asPath, query } = router
const currentLanguage = asPath.includes('/zh') ? 'zh' : 'en'

const changeLanguage = (locale) => {
const currentPath = asPath.split('?')[0]

if (currentPath === '/documentation' || currentPath === '/documentation/') {
router.push(`/documentation/${locale}`)
return
}

const newPath = currentPath.replace(
/\/documentation\/(en|zh)/,
`/documentation/${locale}`
)

router.push(newPath)
}

return (
<Menu as="div" className="relative">
<Menu.Button className="flex items-center gap-2 rounded-lg bg-zinc-800/40 px-3 py-2 text-sm text-white hover:bg-zinc-800 transition-colors duration-200">
{languages.find(l => l.code === currentLanguage)?.name}
<svg
width="8"
height="5"
className="ml-1 stroke-current"
fill="none"
viewBox="0 0 8 5"
>
<path d="M1 1L4 4L7 1" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
</svg>
</Menu.Button>
<Menu.Items as={motion.div}
initial={{ y: -10 }}
animate={{ y: 0 }}
exit={{ y: -10 }}
className="absolute left-0 mt-1 w-40 origin-top-left rounded-lg bg-[#27272A] ring-1 ring-zinc-700 shadow-xl z-50"
>
{languages.map((language) => (
<Menu.Item key={language.code}>
{({ active }) => (
<button
onClick={() => changeLanguage(language.code)}
className={`${
active ? 'bg-zinc-700/50' : ''
} ${
currentLanguage === language.code ? 'bg-orange-500/10 text-orange-500' : 'text-zinc-100'
} group flex w-full items-center gap-2 rounded-md px-3 py-2.5 text-sm transition-colors duration-200`}
>
{language.name}
</button>
)}
</Menu.Item>
))}
</Menu.Items>
</Menu>
)
}

export default LanguageSelector
Loading

0 comments on commit d0c62b1

Please sign in to comment.