Core Concepts
The localization system consists of two main components:Localization
Language preferences for UI text and content metadataFormat:
language-Country (e.g., en-GB, fr-CA)Content Country
Geographic region for content recommendationsFormat: ISO country code (e.g.,
US, DE, JP)Localization affects the language of extracted metadata (titles, descriptions), while Content Country affects which content is shown (e.g., trending videos vary by country).
Localization Class
TheLocalization class represents a language and optional country code:
Creating Localizations
- Constructor
- From Locale
- From Code
- List Creation
Direct instantiation:
Localization Code Format
The localization code follows BCP 47 language tag format:ContentCountry Class
TheContentCountry class represents geographic regions:
Creating Content Countries
Content country codes use ISO 3166-1 alpha-2 format (two-letter codes). Examples:
US, GB, DE, JP, BR, IN.Global Configuration
Set global preferences via theNewPipe class:
During Initialization
After Initialization
Service-Level Localization
EachStreamingService defines supported localizations:
YouTube Example
Localization Resolution
Services resolve user preferences to supported localizations:Resolution Example
Extractor-Level Localization
Individual extractors can override localization:Per-Extractor Configuration
Time Ago Parsing
The localization system includes support for parsing relative time strings:Usage in Extractors
Three-Letter Language Codes
Convert ISO 639-2/T codes to locales:Best Practices
Set Localization Early
Set Localization Early
Initialize localization during app setup:
Respect User Preferences
Respect User Preferences
Use device/browser locale as default:
Handle Unsupported Localizations
Handle Unsupported Localizations
Always check if a service supports the requested localization:
Use Extractor-Level Overrides Sparingly
Use Extractor-Level Overrides Sparingly
Only force localization when necessary:
Test Multiple Localizations
Test Multiple Localizations
Test your implementation with various localizations:
Common Use Cases
Multi-Language Content Extraction
Region-Specific Trending
Related Documentation
Services
Service-level localization
Extractors
Extractor-level overrides
Overview
Architecture overview