Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass arg and fix issues #256

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
3 changes: 2 additions & 1 deletion scripts/generate_blog_translations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { translateText } from './translate'
const batchSize = 20
const contentDirectory = join(process.cwd(), 'src', 'content')
const blogDirectory = join(contentDirectory, 'blog')
const languages = locales.filter((lang) => lang !== defaultLocale)
const localeArgIndex = process.argv.findIndex(arg => arg.startsWith('--locale='))
const languages = localeArgIndex !== -1 ? [process.argv[localeArgIndex].split('=')[1]] : locales.filter((lang) => lang !== defaultLocale)

for (const lang of languages) {
console.log(`Preparing the blogs for locale: ${lang}...`)
Expand Down
4 changes: 3 additions & 1 deletion scripts/generate_locale_translations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import path from 'path'
import { translateText } from './translate'

const batchSize = 200
const locales = ['fr']

const localeArgIndex = process.argv.findIndex(arg => arg.startsWith('--locale='))
const locales = localeArgIndex !== -1 ? [process.argv[localeArgIndex].split('=')[1]] : ['fr']

const localePath = path.join(process.cwd(), 'locales', 'en.yml')

Expand Down
3 changes: 2 additions & 1 deletion scripts/generate_plugin_translations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { defaultLocale, locales } from '../src/services/locale'
import { translateText } from './translate'

const batchSize = 20
const languages = locales.filter((lang) => lang !== defaultLocale)
const localeArgIndex = process.argv.findIndex(arg => arg.startsWith('--locale='))
const languages = localeArgIndex !== -1 ? [process.argv[localeArgIndex].split('=')[1]] : locales.filter((lang) => lang !== defaultLocale)
const contentDirectory = join(process.cwd(), 'src', 'content')
const blogDirectory = join(contentDirectory, 'plugins-tutorials')

Expand Down
8 changes: 4 additions & 4 deletions scripts/setup_new_locale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ copyDirectory(path.join(process.cwd(), 'src', 'content', 'blog'), path.join(proc
console.log(`Done.\n`)

console.log('Generating locale translations...')
execSync('npm run generate:locale:translations', { stdio: 'inherit' })
execSync(`npm run generate:locale:translations -- --locale=${newLocale}`, { stdio: 'inherit' })
console.log('Generating translation.ts...')
execSync('npm run generate:translation.ts', { stdio: 'inherit' })
execSync(`npm run generate:translation.ts -- --locale=${newLocale}`, { stdio: 'inherit' })
console.log('Generating blog translations...')
execSync('npm run generate:blog:translations', { stdio: 'inherit' })
execSync(`npm run generate:blog:translations -- --locale=${newLocale}`, { stdio: 'inherit' })
console.log('Generating plugin translations...')
execSync('npm run generate:plugin:translations', { stdio: 'inherit' })
execSync(`npm run generate:plugin:translations -- --locale=${newLocale}`, { stdio: 'inherit' })
7 changes: 0 additions & 7 deletions scripts/translate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const makeAnthropicRequest = async (body: any) => {
},
body: JSON.stringify(body),
})

if (response.status === 429) {
const retryAfter = response.headers.get('Retry-After')
console.log('Rate limit exceeded. Retrying after:', retryAfter)
Expand All @@ -51,12 +50,10 @@ const makeAnthropicRequest = async (body: any) => {
return makeRequest()
}
}

if (response.status !== 200) {
console.error('Error Claude:', response.statusText, await response.json())
return null
}

return response.json()
}

Expand Down Expand Up @@ -96,11 +93,9 @@ export const translateTextsAnthropic = async (texts: string[], lang: string) =>
})
return data ? JSON.parse(data.content[0].text) as string[] : null
}

const results: string[] = []
let currentBatch: string[] = []
let currentTokens = 0

for (const text of texts) {
const textTokens = Math.ceil(text.length * TOKENS_PER_CHAR)
if (currentTokens + textTokens > MAX_TOKENS) {
Expand All @@ -112,12 +107,10 @@ export const translateTextsAnthropic = async (texts: string[], lang: string) =>
currentBatch.push(text)
currentTokens += textTokens
}

if (currentBatch.length > 0) {
const batchResult = await translateBatch(currentBatch)
if (batchResult) results.push(...batchResult)
}

return results
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /organization_system_blog.webp
head_image_alt: Capgoの組織システムの図解
tag: Story
published: true
locale: jp
locale: ja
next_blog: ''
---

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /appflow_alt.webp
head_image_alt: Appflowの代替図
tag: Alternatives
published: true
locale: jp
locale: ja
next_blog: ''
---

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ head_image: /appflow_alt.webp
head_image_alt: Capawesome Cloud-Illustrationの代替案
tag: Alternatives
published: false
locale: jp
locale: ja
next_blog: ''
---

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /expo_alternative.webp
head_image_alt: Expoの代替図
tag: Alternatives
published: true
locale: jp
locale: ja
next_blog: ''
---

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ head_image: /voltbuilder_alt.webp
head_image_alt: Voltbuilder用の代替イラストレーション
tag: Alternatives
published: true
locale: jp
locale: ja
next_blog: ''
---

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /angular_capacitor.webp
head_image_alt: Angularとキャパシターの図解
tag: Tutorial
published: true
locale: jp
locale: ja
next_blog: update-your-capacitor-apps-seamlessly-using-capacitor-updater
---

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /migrate_appcenter.webp
head_image_alt: Capacitor JS開発者が代替手段を探す
tag: Migration
published: true
locale: jp
locale: ja
next_blog: automatic-build-and-release-with-github-actions
---

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /github_actions.webp
head_image_alt: GitHub アクション イラストレーション
tag: CI/CD
published: true
locale: jp
locale: ja
next_blog: automatic-capacitor-ios-build-github-action
---

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /gitlab_ci.webp
head_image_alt: GitLab CIの図解
tag: CI/CD
published: true
locale: jp
locale: ja
next_blog: ''
---

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /fastlane_android.webp
head_image_alt: GitHub アクション Fastlane Google Play の図解
tag: CI/CD
published: true
locale: jp
locale: ja
next_blog: automatic-capacitor-ios-build-github-action
---

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /andriod_app_gitlab.webp
head_image_alt: Fastlane Google Play のGitLabによるイラストレーション
tag: CI/CD
published: true
locale: jp
locale: ja
next_blog: null
---

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /Codemagic_ios.webp
head_image_alt: Codemagicによるテストフライトのイラストレーション
tag: CI/CD
published: true
locale: jp
locale: ja
next_blog: automatic-capacitor-android-build-codemagic
---

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /fastlane_ios.webp
head_image_alt: GitHub ActionによるFastlane TestFlightのイラスト
tag: CI/CD
published: true
locale: jp
locale: ja
next_blog: automatic-capacitor-android-build-github-action
---

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /fastlane_ios.webp
head_image_alt: GitHub Action による Fastlane TestFlight の図解
tag: CI/CD
published: true
locale: jp
locale: ja
next_blog: automatic-capacitor-android-build-github-action
---

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ head_image: /native_app_look.webp
head_image_alt: ネイティブアプリケーションの外観の図解
tag: Web Development
published: true
locale: jp
locale: ja
next_blog: ''
---

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ head_image: /capgo-birth-story.webp
head_image_alt: Capgoのアイデアから製品までの進化の視覚的表現
tag: development
published: true
locale: jp
locale: ja
next_blog: ''
---

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /next_capgo.webp
head_image_alt: Next.js 14 と Capacitor の説明
tag: Tutorial
published: true
locale: jp
locale: ja
next_blog: update-your-capacitor-apps-seamlessly-using-capacitor-updater
---

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /nuxt_capgo.webp
head_image_alt: Nuxt 3とCapgoのイラスト
tag: Tutorial
published: true
locale: jp
locale: ja
next_blog: update-your-capacitor-apps-seamlessly-using-capacitor-updater
---

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ head_image: /capacitor-guide.webp
head_image_alt: Capacitorガイドのイラスト
tag: Guides
published: true
locale: jp
locale: ja
next_blog: ''
---

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ head_image_alt: Capgoの組織システムの図解
tag: Capacitor
published: true
next_blog: ''
locale: jp
locale: ja
---

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ head_image: /capgo_banner.webp
head_image_alt: キャプゴバナー
tag: SOLUTION
published: true
locale: jp
locale: ja
next_blog: ''
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /react_native_vs_react_capacitor.webp
head_image_alt: React NativeとCapacitorの比較
tag: Alternatives
published: true
locale: jp
locale: ja
next_blog: ''
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /what-is-cordova-phone-gap.webp
head_image_alt: ハイブリッドアプリケーションとネイティブアプリケーションの違いを説明する図。
tag: cordova
published: true
locale: jp
locale: ja
next_blog: ''
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /vue_angular_react.webp
head_image_alt: コンピュータで作業している人の画像。
tag: Tutorial
published: true
locale: jp
locale: ja
next_blog: ''
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /react_capacitor.webp
head_image_alt: ReactとCapacitorのイラスト
tag: Tutorial
published: true
locale: jp
locale: ja
next_blog: update-your-capacitor-apps-seamlessly-using-capacitor-updater
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /react_capacitor.webp
head_image_alt: React.jsとCapacitorのイラスト
tag: Tutorial
published: true
locale: jp
locale: ja
next_blog: implementing-live-updates-in-your-react-capacitor-app
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ head_image: /sveltekit_capacitor.webp
head_image_alt: SvelteKitとCapgoのイラスト
tag: Tutorial
published: true
locale: jp
locale: ja
next_blog: updating-your-capacitor-apps-seamlessly-with-capacitor-updater
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ head_image: /cross-platform-app-dev-2024.webp
head_image_alt: クロスプラットフォームモバイルアプリケーション開発
tag: cross-platform
published: true
locale: jp
locale: ja
next_blog: top-cross-platform-frameworks-compared-2024
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ head_image: /create_app_with_js.webp
head_image_alt: マルチプラットフォームアプリケーション開発
tag: Tuto
published: true
locale: jp
locale: ja
next_blog: ''
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /apple_appstore.webp
head_image_alt: キャパシタ回避装置のイラスト
tag: Tutorial
published: true
locale: jp
locale: ja
next_blog: update-your-capacitor-apps-seamlessly-using-capacitor-updater
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /cordova.webp
head_image_alt: カオロドヴァ・デブは、アプリケーションのアップデートを探しています。
tag: Migration
published: true
locale: jp
locale: ja
next_blog: ''
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /playstore.webp
head_image_alt: コンデンサーの導関数の表現
tag: Tutorial
published: true
locale: jp
locale: ja
next_blog: update-your-capacitor-apps-seamlessly-using-capacitor-updater
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ head_image: /enable-ios-developer-mode-ios16.webp
head_image_alt: iPhoneで開発者モードを有効にする
tag: iOS
published: true
locale: jp
locale: ja
next_blog: ''
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ created_at: 2024-09-22T00:00:00.000Z
updated_at: 2024-09-22T00:00:00.000Z
tag: Case Study
published: true
locale: jp
locale: ja
next_blog: ''
---

Expand Down
Loading
Loading