Skip to content

Commit

Permalink
Add support for xcode and android
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 26, 2024
1 parent 5e58376 commit 2deef11
Show file tree
Hide file tree
Showing 14 changed files with 717 additions and 11 deletions.
49 changes: 49 additions & 0 deletions apps/web/src/components/commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,55 @@ export function Commands() {
>
│ ○ Markdown (.md)
</span>
<span
className={cn(
"transition-opacity duration-100",
step >= 4 ? "opacity-100" : "opacity-0",
)}
>
│ ○ Xcode Strings (.strings)
</span>
<span
className={cn(
"transition-opacity duration-100",
step >= 4 ? "opacity-100" : "opacity-0",
)}
>
│ ○ Xcode Stringsdict (.stringsdict)
</span>
<span
className={cn(
"transition-opacity duration-100",
step >= 4 ? "opacity-100" : "opacity-0",
)}
>
│ ○ Xcode XCStrings (.xcstrings)
</span>
<span
className={cn(
"transition-opacity duration-100",
step >= 4 ? "opacity-100" : "opacity-0",
)}
>
│ ○ YAML (.yml)
</span>
<span
className={cn(
"transition-opacity duration-100",
step >= 4 ? "opacity-100" : "opacity-0",
)}
>
│ ○ Gettext (.po)
</span>
<span
className={cn(
"transition-opacity duration-100",
step >= 4 ? "opacity-100" : "opacity-0",
)}
>
│ ○ Android (.xml)
</span>

<span
className={cn(
"transition-opacity duration-100",
Expand Down
Binary file modified bun.lockb
Binary file not shown.
16 changes: 16 additions & 0 deletions examples/android/languine.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
version: "0.6.2",
locale: {
source: "en",
targets: ["es"],
},
files: {
android: {
include: ["locales/[locale].xml"],
},
},
llm: {
provider: "openai",
model: "gpt-4-turbo",
},
};
66 changes: 66 additions & 0 deletions examples/android/locales/en.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Navigation -->
<string name="nav_home">Home</string>
<string name="nav_search">Search</string>
<string name="nav_favorites">Favorites</string>
<string name="nav_settings">Settings</string>

<!-- User Profile -->
<string name="profile_title">My Profile</string>
<string name="profile_edit">Edit Profile</string>
<string name="profile_save">Save Changes</string>
<string name="profile_logout">Sign Out</string>

<!-- Media Player -->
<plurals name="media_queue">
<item quantity="one">%d song in queue</item>
<item quantity="other">%d songs in queue</item>
</plurals>
<string name="media_play">Play</string>
<string name="media_pause">Pause</string>
<string name="media_next">Next Track</string>
<string name="media_previous">Previous Track</string>

<!-- Shopping Cart -->
<string name="cart_title">Shopping Cart</string>
<string name="cart_total">Total: $%1$.2f</string>
<string name="cart_checkout">Proceed to Checkout</string>
<string-array name="payment_methods">
<item>Credit Card</item>
<item>PayPal</item>
<item>Bank Transfer</item>
</string-array>

<!-- Weather -->
<string name="weather_current">Current Temperature: %1$d°</string>
<string name="weather_humidity">Humidity: %1$d%%</string>
<string name="weather_wind">Wind Speed: %1$d mph</string>

<!-- Notifications -->
<string name="notification_new_message">%1$s sent you a message</string>
<string name="notification_friend_request">New friend request from %1$s</string>
<plurals name="notification_likes">
<item quantity="one">%d person liked your post</item>
<item quantity="other">%d people liked your post</item>
</plurals>

<!-- Error Messages -->
<string name="error_network">Unable to connect to network</string>
<string name="error_timeout">Request timed out</string>
<string name="error_invalid_input">Invalid input provided</string>

<!-- Calendar -->
<string name="calendar_event_title">Event: %1$s</string>
<string name="calendar_event_time">Time: %1$s - %2$s</string>
<string name="calendar_event_location">Location: %1$s</string>

<!-- Game -->
<string name="game_score">Score: %1$d</string>
<string name="game_high_score">High Score: %1$d</string>
<string name="game_lives_left">Lives: %1$d</string>
<plurals name="game_achievements">
<item quantity="one">%d achievement unlocked</item>
<item quantity="other">%d achievements unlocked</item>
</plurals>
</resources>
48 changes: 48 additions & 0 deletions examples/android/locales/es.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<resources>
<string name="nav_home">Inicio</string>
<string name="nav_search">Buscar</string>
<string name="nav_favorites">Favoritos</string>
<string name="nav_settings">Configuración</string>
<string name="profile_title">Mi Perfil</string>
<string name="profile_edit">Editar Perfil</string>
<string name="profile_save">Guardar Cambios</string>
<string name="profile_logout">Cerrar Sesión</string>
<string name="media_play">Reproducir</string>
<string name="media_pause">Pausa</string>
<string name="media_next">Siguiente Canción</string>
<string name="media_previous">Canción Anterior</string>
<string name="cart_title">Carrito de Compras</string>
<string name="cart_total">Total: $%1$.2f</string>
<string name="cart_checkout">Proceder al Pago</string>
<string name="weather_current">Temperatura Actual: %1$d°</string>
<string name="weather_humidity">Humedad: %1$d%%</string>
<string name="weather_wind">Velocidad del Viento: %1$d mph</string>
<string name="notification_new_message">%1$s te ha enviado un mensaje</string>
<string name="notification_friend_request">Nueva solicitud de amistad de %1$s</string>
<string name="error_network">No se puede conectar a la red</string>
<string name="error_timeout">Tiempo de solicitud agotado</string>
<string name="error_invalid_input">Entrada inválida proporcionada</string>
<string name="calendar_event_title">Evento: %1$s</string>
<string name="calendar_event_time">Hora: %1$s - %2$s</string>
<string name="calendar_event_location">Ubicación: %1$s</string>
<string name="game_score">Puntuación: %1$d</string>
<string name="game_high_score">Puntuación Más Alta: %1$d</string>
<string name="game_lives_left">Vidas: %1$d</string>
<string-array name="payment_methods">
<item>Tarjeta de Crédito</item>
<item>PayPal</item>
<item>Transferencia Bancaria</item>
</string-array>
<plurals name="media_queue">
<item quantity="one">%d canción en cola</item>
<item quantity="other">%d canciones en cola</item>
</plurals>
<plurals name="notification_likes">
<item quantity="one">%d persona le gustó tu publicación</item>
<item quantity="other">%d personas les gustó tu publicación</item>
</plurals>
<plurals name="game_achievements">
<item quantity="one">%d logro desbloqueado</item>
<item quantity="other">%d logros desbloqueados</item>
</plurals>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>product_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@items@</string>
<key>items</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>No items available</string>
<key>one</key>
<string>One item available</string>
<key>two</key>
<string>Two items available</string>
<key>few</key>
<string>%lld items available</string>
<key>many</key>
<string>%lld items available</string>
<key>other</key>
<string>%lld items available</string>
</dict>
</dict>
<key>countdown_days</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@days@</string>
<key>days</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>Event starts today!</string>
<key>one</key>
<string>Event starts tomorrow!</string>
<key>two</key>
<string>Event starts in two days</string>
<key>few</key>
<string>Event starts in %lld days</string>
<key>many</key>
<string>Event starts in %lld days</string>
<key>other</key>
<string>Event starts in %lld days</string>
</dict>
</dict>
<key>hello</key>
<string>Hi there!</string>
<key>user_welcome</key>
<string>Welcome back, %@!</string>
<key>score_format</key>
<string>Player %1$@ has earned %2$lld points with $%3$.2f remaining</string>
<key>current_date</key>
<string>Current date: %@</string>
<key>formatted_message</key>
<string>Here's a &lt;b&gt;formatted&lt;/b&gt; message with:
• HTML formatting
• Special symbols: ©®™
• A &lt;a href="https://example.com"&gt;hyperlink&lt;/a&gt;</string>
<key>alert_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@notifications@</string>
<key>notifications</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>No new notifications</string>
<key>one</key>
<string>One new notification</string>
<key>other</key>
<string>%lld new notifications</string>
</dict>
</dict>
<key>remaining_time</key>
<string>Time remaining: %1$@ (%2$lld seconds)</string>
<key>version_info</key>
<string>Version %1$@ (Build %2$@)</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>product_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@items@</string>
<key>items</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>No hay artículos disponibles</string>
<key>one</key>
<string>Un artículo disponible</string>
<key>two</key>
<string>Dos artículos disponibles</string>
<key>few</key>
<string>%lld artículos disponibles</string>
<key>many</key>
<string>%lld artículos disponibles</string>
<key>other</key>
<string>%lld artículos disponibles</string>
</dict>
</dict>
<key>countdown_days</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@days@</string>
<key>days</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>¡El evento comienza hoy!</string>
<key>one</key>
<string>El evento comienza mañana!</string>
<key>two</key>
<string>El evento comienza en dos días</string>
<key>few</key>
<string>El evento comienza en %lld días</string>
<key>many</key>
<string>El evento comienza en %lld días</string>
<key>other</key>
<string>El evento comienza en %lld días</string>
</dict>
</dict>
<key>hello</key>
<string>¡Hola!</string>
<key>user_welcome</key>
<string>¡Bienvenido de nuevo, %@!</string>
<key>score_format</key>
<string>El jugador %1$@ ha ganado %2$lld puntos con $%3$.2f restantes</string>
<key>current_date</key>
<string>Fecha actual: %@</string>
<key>formatted_message</key>
<string>Aquí tienes un mensaje &lt;b&gt;formateado&lt;/b&gt; con:
• Formato HTML
• Símbolos especiales: ©®™
• Un &lt;a href="https://example.com"&gt;hipervínculo&lt;/a&gt;</string>
<key>alert_count</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@notifications@</string>
<key>notifications</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>lld</string>
<key>zero</key>
<string>No hay nuevas notificaciones</string>
<key>one</key>
<string>Una nueva notificación</string>
<key>other</key>
<string>%lld nuevas notificaciones</string>
</dict>
</dict>
<key>remaining_time</key>
<string>Tiempo restante: %1$@ (%2$lld segundos)</string>
<key>version_info</key>
<string>Versión %1$@ (Construcción %2$@)</string>
</dict>
</plist>
16 changes: 16 additions & 0 deletions examples/xcode-stringsdict/languine.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
version: "0.6.2",
locale: {
source: "en",
targets: ["es"],
},
files: {
"xcode-stringsdict": {
include: ["Example/[locale].lproj/Localizable.stringsdict"],
},
},
llm: {
provider: "openai",
model: "gpt-4-turbo",
},
}
2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ developer-friendly experience.

- Automatically identifies new, modified, or removed translation keys in your
codebase using Git diff
- Handles multiple file formats (.json, .ts, .md) with precise parsing and
- Handles multiple file formats (.json, .ts, .md, .yaml, .po, .strings, .stringsdict, .xcstrings) with precise parsing and
file-specific updates

### 🌍 AI-Powered Translation
Expand Down
Loading

0 comments on commit 2deef11

Please sign in to comment.