Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 18, 2025

This PR adds three comprehensive vignettes to demonstrate key polyglotr package functionality for multilingual workflows and localization projects:

πŸ“š New Vignettes Added

1. Translation Table Workflow (translation-table-workflow.Rmd)

Demonstrates how to use create_translation_table() to translate vectors of phrases across multiple languages:

# Basic usage
ui_phrases <- c("Welcome", "Login", "Password", "Submit", "Cancel")
languages <- c("es", "fr", "de", "it")
translation_table <- create_translation_table(ui_phrases, languages)

Features:

  • Multiple API comparison (Google Translate + MyMemory)
  • Tidyverse integration for advanced workflows
  • Tabular output format for easy reference
  • Best practices for localization projects

2. File Translation Workflow (file-translation-workflow.Rmd)

Shows end-to-end automation for translating .txt and .csv files using translate_file():

# Translate entire files with encoding support
translate_file(
  file_path = "documentation.txt",
  target_language = "es",
  source_language = "en",
  overwrite = FALSE  # Creates new translated file
)

Features:

  • Different file type handling
  • Encoding considerations (UTF-8 support)
  • Overwrite vs. new file options
  • Batch processing workflows
  • Robust error handling

3. Language Detection and Conditional Translation (language-detection-conditional-translation.Rmd)

Demonstrates smart processing of mixed-language datasets:

# Detect language and translate only non-English content
mixed_data <- tibble(
  feedback = c("Great product!", "Excelente producto!", "Produit fantastique!")
)

# Process with conditional translation
processed_data <- mixed_data %>%
  mutate(
    detected_lang = map_chr(feedback, language_detect),
    needs_translation = !str_detect(detected_lang, "en"),
    english_text = ifelse(needs_translation, 
                         google_translate(feedback), 
                         feedback)
  )

Features:

  • Language detection with language_detect()
  • Conditional translation (translate only non-English text)
  • Tidyverse integration for data cleaning
  • Quality control and error handling

πŸ”§ Integration Details

  • All vignettes have proper YAML headers with VignetteIndexEntry
  • Follow existing package vignette style and format
  • Will be automatically detected by pkgdown for website display under Articles
  • Include comprehensive examples and best practices
  • Code chunks use eval = FALSE to avoid API calls during build

πŸ“‹ Use Cases

These vignettes help users with:

  • Localization projects: Translating UI elements and documentation
  • Data cleaning: Processing multilingual user-generated content
  • Document automation: Batch translating files and exports
  • Quality assurance: Comparing translation APIs for accuracy

Fixes #22.


πŸ’‘ You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Request: Vignettes Add comprehensive vignettes for translation workflows and language detection Jul 18, 2025
Copilot finished work on behalf of tin900 July 18, 2025 16:10
@Copilot Copilot AI requested a review from tin900 July 18, 2025 16:10
Deleted the 'file-translation-workflow.Rmd' vignette. Cleaned up and streamlined 'language-detection-conditional-translation.Rmd' by removing text analysis and error handling sections, and updated package usage. Also removed the best practices code example from 'translation-table-workflow.Rmd' for a more concise vignette.
@tin900 tin900 marked this pull request as ready for review July 23, 2025 06:26
@tin900 tin900 merged commit 02ad61f into main Jul 23, 2025
4 checks passed
@tin900 tin900 deleted the copilot/fix-22 branch July 23, 2025 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request: Vignettes

2 participants