[PR #55] [MERGED] Add Multi-Language Support with Accept-Language Header #56

Closed
opened 2026-02-27 19:06:39 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Aran404/SpotAPI/pull/55
Author: @ParkJeongseop
Created: 12/19/2025
Status: Merged
Merged: 12/19/2025
Merged by: @Aran404

Base: mainHead: feature/add-language-support


📝 Commits (1)

  • f3fe30d feat: add multi-language support with Accept-Language header

📊 Changes

12 files changed (+210 additions, -12 deletions)

View changed files

📝 README.md (+17 -1)
📝 docs/album.md (+19 -1)
📝 docs/artist.md (+25 -1)
docs/language.md (+90 -0)
📝 docs/playlist.md (+19 -1)
📝 docs/song.md (+19 -1)
📝 spotapi/album.py (+2 -1)
📝 spotapi/artist.py (+2 -1)
📝 spotapi/client.py (+8 -1)
📝 spotapi/playlist.py (+5 -2)
📝 spotapi/podcast.py (+2 -1)
📝 spotapi/song.py (+2 -1)

📄 Description

Summary

This PR adds comprehensive multi-language support to SpotAPI by implementing Accept-Language header functionality across all major classes. Users can now receive localized responses from Spotify's API in their preferred language using standard ISO 639-1 language codes.

Changes Made

Core Implementation

  • BaseClient Enhancement: Added language parameter and Accept-Language header support in spotapi/client.py
  • Runtime Language Switching: Added set_language() method for dynamic language changes
  • All Major Classes Updated: Added language support to:
    • Artist
    • Song
    • PublicPlaylist
    • PrivatePlaylist
    • PublicAlbum
    • Podcast

Documentation Updates

  • README.md: Added language support to features list and usage examples
  • Module Documentation: Updated individual docs with language parameters and examples
  • New Language Guide: Created comprehensive docs/language.md documentation

Features

ISO 639-1 Standard: Support for standard language codes (ko, ja, zh, en, etc.)
Runtime Language Changes: Switch languages without reinitializing objects
Backward Compatible: Default English, existing code continues to work
Comprehensive Coverage: Available in all major SpotAPI classes
Centralized Implementation: DRY principle with BaseClient handling headers

Usage Examples

Initialize with Language

from spotapi import Artist, Song

# Korean language
artist = Artist(language="ko")
song = Song(language="ko")

# Get track info with Korean language
track_info = song.get_track_info("5QDLhrAOJJdNAmCTJ8xMyW")  # Returns "좋은 날"

Runtime Language Changes

# Start with English
artist = Artist(language="en")

# Switch to Korean
artist.base.set_language("ko")

# Switch to Japanese  
artist.base.set_language("ja")

Testing

Thoroughly tested with real Spotify tracks:

  • Korean track info retrieval: "좋은 날" (track ID: 5QDLhrAOJJdNAmCTJ8xMyW)
  • Korean search functionality: "아이유" search returns localized results
  • Header verification: Accept-Language properly applied to all requests
  • Language switching: Runtime language changes work correctly

Technical Details

Implementation Approach

  • Centralized: Language handling in BaseClient._auth_rule() method
  • Automatic: Accept-Language header added to all authenticated requests
  • Consistent: Same pattern across all classes extending BaseClient

Header Example

Accept-Language: ko
Authorization: Bearer <token>
Client-Token: <client_token>
Spotify-App-Version: <version>

Backward Compatibility

  • No Breaking Changes: All existing code continues to work
  • Default Behavior: English language by default (language="en")
  • Optional Parameter: Language parameter is optional in all constructors

Files Changed

Core Files

  • spotapi/client.py - Added language support to BaseClient
  • spotapi/artist.py - Added language parameter
  • spotapi/song.py - Added language parameter
  • spotapi/playlist.py - Added language parameter (both Public and Private)
  • spotapi/album.py - Added language parameter
  • spotapi/podcast.py - Added language parameter

Documentation

  • README.md - Added features and examples
  • docs/artist.md - Added language documentation
  • docs/song.md - Added language documentation
  • docs/playlist.md - Added language documentation
  • docs/album.md - Added language documentation
  • docs/language.md - New comprehensive language guide

Benefits

🌍 Global Accessibility: Makes SpotAPI usable for international developers
🎯 User Experience: Localized responses improve user experience
📚 Well Documented: Comprehensive documentation with examples
🔧 Easy to Use: Simple API with sensible defaults
Performance: No overhead when using default language

This enhancement significantly improves SpotAPI's international usability while maintaining its simplicity and existing functionality.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Aran404/SpotAPI/pull/55 **Author:** [@ParkJeongseop](https://github.com/ParkJeongseop) **Created:** 12/19/2025 **Status:** ✅ Merged **Merged:** 12/19/2025 **Merged by:** [@Aran404](https://github.com/Aran404) **Base:** `main` ← **Head:** `feature/add-language-support` --- ### 📝 Commits (1) - [`f3fe30d`](https://github.com/Aran404/SpotAPI/commit/f3fe30d67bdcd7bf643b6914a1241efe628f6137) feat: add multi-language support with Accept-Language header ### 📊 Changes **12 files changed** (+210 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+17 -1) 📝 `docs/album.md` (+19 -1) 📝 `docs/artist.md` (+25 -1) ➕ `docs/language.md` (+90 -0) 📝 `docs/playlist.md` (+19 -1) 📝 `docs/song.md` (+19 -1) 📝 `spotapi/album.py` (+2 -1) 📝 `spotapi/artist.py` (+2 -1) 📝 `spotapi/client.py` (+8 -1) 📝 `spotapi/playlist.py` (+5 -2) 📝 `spotapi/podcast.py` (+2 -1) 📝 `spotapi/song.py` (+2 -1) </details> ### 📄 Description ## Summary This PR adds comprehensive multi-language support to SpotAPI by implementing `Accept-Language` header functionality across all major classes. Users can now receive localized responses from Spotify's API in their preferred language using standard ISO 639-1 language codes. ## Changes Made ### Core Implementation - **BaseClient Enhancement**: Added `language` parameter and `Accept-Language` header support in `spotapi/client.py` - **Runtime Language Switching**: Added `set_language()` method for dynamic language changes - **All Major Classes Updated**: Added language support to: - `Artist` - `Song` - `PublicPlaylist` - `PrivatePlaylist` - `PublicAlbum` - `Podcast` ### Documentation Updates - **README.md**: Added language support to features list and usage examples - **Module Documentation**: Updated individual docs with language parameters and examples - **New Language Guide**: Created comprehensive `docs/language.md` documentation ## Features ✅ **ISO 639-1 Standard**: Support for standard language codes (ko, ja, zh, en, etc.) ✅ **Runtime Language Changes**: Switch languages without reinitializing objects ✅ **Backward Compatible**: Default English, existing code continues to work ✅ **Comprehensive Coverage**: Available in all major SpotAPI classes ✅ **Centralized Implementation**: DRY principle with BaseClient handling headers ## Usage Examples ### Initialize with Language ```python from spotapi import Artist, Song # Korean language artist = Artist(language="ko") song = Song(language="ko") # Get track info with Korean language track_info = song.get_track_info("5QDLhrAOJJdNAmCTJ8xMyW") # Returns "좋은 날" ``` ### Runtime Language Changes ```python # Start with English artist = Artist(language="en") # Switch to Korean artist.base.set_language("ko") # Switch to Japanese artist.base.set_language("ja") ``` ## Testing Thoroughly tested with real Spotify tracks: - ✅ Korean track info retrieval: "좋은 날" (track ID: 5QDLhrAOJJdNAmCTJ8xMyW) - ✅ Korean search functionality: "아이유" search returns localized results - ✅ Header verification: `Accept-Language` properly applied to all requests - ✅ Language switching: Runtime language changes work correctly ## Technical Details ### Implementation Approach - **Centralized**: Language handling in `BaseClient._auth_rule()` method - **Automatic**: `Accept-Language` header added to all authenticated requests - **Consistent**: Same pattern across all classes extending BaseClient ### Header Example ``` Accept-Language: ko Authorization: Bearer <token> Client-Token: <client_token> Spotify-App-Version: <version> ``` ## Backward Compatibility - ✅ **No Breaking Changes**: All existing code continues to work - ✅ **Default Behavior**: English language by default (`language="en"`) - ✅ **Optional Parameter**: Language parameter is optional in all constructors ## Files Changed ### Core Files - `spotapi/client.py` - Added language support to BaseClient - `spotapi/artist.py` - Added language parameter - `spotapi/song.py` - Added language parameter - `spotapi/playlist.py` - Added language parameter (both Public and Private) - `spotapi/album.py` - Added language parameter - `spotapi/podcast.py` - Added language parameter ### Documentation - `README.md` - Added features and examples - `docs/artist.md` - Added language documentation - `docs/song.md` - Added language documentation - `docs/playlist.md` - Added language documentation - `docs/album.md` - Added language documentation - `docs/language.md` - New comprehensive language guide ## Benefits 🌍 **Global Accessibility**: Makes SpotAPI usable for international developers 🎯 **User Experience**: Localized responses improve user experience 📚 **Well Documented**: Comprehensive documentation with examples 🔧 **Easy to Use**: Simple API with sensible defaults ⚡ **Performance**: No overhead when using default language This enhancement significantly improves SpotAPI's international usability while maintaining its simplicity and existing functionality. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 19:06:39 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SpotAPI#56
No description provided.