# Locale Management Module

This module provides comprehensive locale and regional settings management for the ACoreX Platform.

## Features

- **Locale Profile Management**: Manage locale profiles with calendar, format, and unit settings
- **Language Management**: Handle multiple languages and translations
- **Timezone Management**: Configure timezone settings and conversions
- **Currency Management**: Manage currency formats and symbols
- **Regional Settings**: User-specific regional preferences

## Integration with ACoreX UI Library

This module integrates with the ACoreX UI Library's locale system by providing a custom `AXLocaleProfileProvider` implementation.

### How It Works

1. **Profile Provider Service**: `AXMLocaleProfileProviderService` implements the `AXLocaleProfileProvider` interface
2. **Token Registration**: The service is registered with `AX_LOCALE_PROFILE_PROVIDERS` token
3. **Profile Override**: Platform profiles override the default UI library profiles
4. **Seamless Integration**: The UI library automatically uses platform profiles when available

### Benefits

- **Centralized Management**: All locale profiles managed in one place
- **Platform Control**: Platform can override default UI library behavior
- **Consistent Experience**: Users see the same locale settings across the platform
- **Extensibility**: Easy to add new locales and customize existing ones

## Usage

### Basic Integration

The integration is automatic when the `AXMLocaleManagementModule` is imported. The module registers the profile provider service, which will be used by the UI library.

### Manual Profile Access

```typescript
import { AXMLocaleProfileProviderService } from '@acorex/modules/locale-management';

export class YourService {
  constructor(private profileProvider: AXMLocaleProfileProviderService) {}

  async checkLocaleAvailability() {
    const codes = await this.profileProvider.getAvailableLocaleCodes();
    const hasLocale = await this.profileProvider.hasLocale('en-US');
    
    console.log('Available locales:', codes);
    console.log('Has en-US:', hasLocale);
  }
}
```

### Profile Data Structure

The module provides profiles that extend the core `AXLocaleProfile` interface:

```typescript
interface AXPLocaleProfile extends AXLocaleProfile {
  code: string;           // Locale code (e.g., 'en-US')
  title: string;          // Display name (e.g., 'English (United States)')
  nativeTitle: string;    // Native language name
  // ... other properties from AXLocaleProfile
}
```

## Configuration

### Adding New Locales

1. Add the locale profile to `libs/modules/locale-management/src/lib/features/shared/data/profiles.ts`
2. Import the base profile from `@acorex/core/locale`
3. Extend with platform-specific properties

### Customizing Existing Profiles

Modify the profiles array in the data file to override default behavior:

```typescript
export const profiles: AXPLocaleProfile[] = [
  {
    ...AXUSLocaleProfile,
    code: 'en-US',
    title: 'English (United States)',
    nativeTitle: 'English (United States)',
    // Customize calendar, formats, or units as needed
  },
  // ... other profiles
];
```

## Architecture

```
┌─────────────────────────────────────────────────────────────┐
│                    ACoreX UI Library                       │
│  ┌─────────────────────────────────────────────────────┐   │
│  │           AXLocaleProfileProviderService            │   │
│  │              (Default Implementation)               │   │
│  └─────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘
                              │
                              │ Token: AX_LOCALE_PROFILE_PROVIDERS
                              │
┌─────────────────────────────────────────────────────────────┐
│                Locale Management Module                    │
│  ┌─────────────────────────────────────────────────────┐   │
│  │         AXMLocaleProfileProviderService             │   │
│  │           (Platform Implementation)                 │   │
│  └─────────────────────────────────────────────────────┘   │
│                              │                             │
│  ┌─────────────────────────────────────────────────────┐   │
│  │            AXMLocaleManagementService               │   │
│  │              (Data Source)                         │   │
│  └─────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────┘
```

## Error Handling

The profile provider includes comprehensive error handling:

- **Profile Loading Errors**: Logged with fallback to empty result
- **Individual Profile Errors**: Logged with profile skipping
- **Validation Errors**: Invalid profiles are skipped with warnings
- **Fallback Behavior**: System gracefully degrades if profiles fail to load

## Dependencies

- `@acorex/core/locale`: Core locale types and interfaces
- `@acorex/platform/common`: Platform-specific types and services
- `@acorex/platform/core`: Core platform services

## Related Services

- `AXMLocaleManagementService`: Main service for locale operations
- `AXPRegionalStoreService`: Regional settings store
- `AXMLocaleProfileProviderService`: Profile provider integration
