options.ts
Overview
The options.ts file serves as a centralized repository of predefined option lists used throughout the application. These options primarily represent various language, country, and service-specific categorical selections. The structure and grouping of these options facilitate consistent UI dropdowns, form selections, and API integrations for multilingual and internationalized features.
The file exports multiple constants, each representing an array of objects or strings that describe:
Language options for various translation services (Google, Bing, DeepL, Baidu, etc.)
Country options for Google and Bing services
Domain and source language options for Baidu translation
Weather-related options for QWeather API integration
Database SQL dialect options
Query types and categories for finance and data services (e.g., WenCai, Jin10, TuShare)
Output format options for web crawlers
All options are formatted for direct consumption by UI components or for mapping to external API parameters.
Detailed Descriptions of Exports
1. LanguageOptions: Array<{value: string, label: string}>
Description: Provides a list of language codes and their human-readable labels, covering multiple languages worldwide. This list is likely used in generic language pickers.
Structure: Each item is an object with:
value: ISO or custom language code (string)label: Language name in native or English script (string)
Example:
{ value: 'en', label: 'English' }
Usage:
import { LanguageOptions } from './options';
<select>
{LanguageOptions.map(opt => (
<option key={opt.value} value={opt.value}>{opt.label}</option>
))}
</select>
2. GoogleLanguageOptions: Array<{label: string, value: string}>
Description: Languages supported by the Google translation API. The data originates as objects with
language_codeandlanguage_nameand is transformed into{ label, value }pairs for UI usage.Properties:
label: Language name as recognized by Googlevalue: Language code used by Google Translate
Implementation detail: The original language list is mapped at the end to conform to { label, value }.
3. GoogleCountryOptions: Array<{label: string, value: string}>
Description: Country codes and names conforming to Google API conventions, formatted for selection components.
Properties:
label: Full country namevalue: Country code (typically ISO alpha-2, lowercase)
4. BingCountryOptions: Array<{label: string, value: string}>
Description: Country options for Bing services, with label containing the country name and uppercase country code, and value as the uppercase country code.
Example:
{ label: 'Argentina AR', value: 'AR' }
5. BingLanguageOptions: Array<{label: string, value: string}>
Description: Language options for Bing translation APIs.
Properties:
label: Language with code (e.g., "Arabic ar")value: Language code (e.g., "ar")
6. DeepLSourceLangOptions: Array<{label: string, value: string}> and DeepLTargetLangOptions: Array<{label: string, value: string}>
Description: Supported source and target languages for DeepL translation API.
Properties:
label: Language name (some with extra info like region or notes)value: Language code used by DeepL (uppercase, sometimes region-specific)
7. BaiduFanyiDomainOptions: string[]
Description: Specific domain categories for Baidu's translation service, allowing domain-specific translation optimization.
Example values:
'it','finance','machinery'.
8. BaiduFanyiSourceLangOptions: string[]
Description: Supported source languages for Baidu Translate API, represented as strings.
Special Note: Includes
'auto'for automatic detection.
9. QWeatherLangOptions: string[]
Description: Language codes supported by the QWeather API.
Example:
'zh','en','de','fr'.
10. QWeatherTypeOptions: string[]
Description: Types of data requests available from QWeather.
Values:
'weather','indices','airquality'.
11. QWeatherUserTypeOptions: string[]
Description: User subscription types for QWeather API.
Values:
'free','paid'.
12. QWeatherTimePeriodOptions: string[]
Description: Time period options for weather forecasts.
Values:
'now','3d','7d','10d','15d','30d'.
13. ExeSQLOptions: Array<{label: string, value: string}>
Description: SQL dialect options supported for execution or connection.
Implementation detail: Uses Lodash's
upperFirstto capitalize the label while keeping the value lowercase.Example:
{ label: 'Mysql', value: 'mysql' }
14. WenCaiQueryTypeOptions: string[]
Description: Different query types supported by WenCai financial data service.
Examples:
'stock','fund','usstock','foreign_exchange'.
15. Jin10 Options
Jin10TypeOptions: Main categories such as'flash','calendar','symbols','news'.Jin10FlashTypeOptions: Array of strings'1'to'5'representing flash categories.Jin10CalendarTypeOptions: Calendar types like'cj','qh','hk','us'.Jin10CalendarDatashapeOptions: Data shapes like'data','event','holiday'.Jin10SymbolsTypeOptions: Symbol categories like'GOODS','FOREX','FUTURE','CRYPTO'.Jin10SymbolsDatatypeOptions: Data types such as'symbols','quotes'.
16. TuShareSrcOptions: string[]
Description: Data source options for the TuShare financial data API.
Examples:
'sina','eastmoney','jinrongjie'.
17. CrawlerResultOptions: string[]
Description: Output formats for web crawler results.
Values:
'markdown','html','content'.
Important Implementation Details
The file imports
upperFirstfromlodashto format labels inExeSQLOptions.Several arrays (e.g.,
GoogleLanguageOptions,GoogleCountryOptions) are initialized as an array of raw objects and then mapped into the{ label, value }format for UI consistency.Language and country codes follow the conventions of their respective services, which may differ (e.g., Google uses lowercase country codes, Bing uses uppercase).
The file does not contain functions or classes but instead exports constant data structures.
The lists are mostly static and hardcoded, making this file a single source of truth for language and country options used in the application.
Duplicate entries (e.g.,
'fr'French language inLanguageOptions) are present but generally harmless for usage as dropdown options.
Interaction with Other Parts of the System
This file is likely imported by UI components responsible for rendering language and country selection dropdowns.
It is also used by modules that integrate with external APIs (Google Translate, Bing, DeepL, Baidu Translate, QWeather, WenCai, Jin10, TuShare) to ensure consistent parameter passing.
The options arrays serve as validation or autocomplete data for user inputs or configuration settings.
Since the options correspond to external services' codes and labels, this file acts as a bridge between UI selections and API parameters.
For example, a language picker component might import
GoogleLanguageOptionsto let users select a language for translation requests.
Visual Diagram
The file primarily contains exported constants grouped as arrays of options. A flowchart best visualizes the relationships and usage of these option sets in the system.
flowchart TD
A[options.ts] -->|Exports| B[LanguageOptions]
A -->|Exports| C[GoogleLanguageOptions]
A -->|Exports| D[GoogleCountryOptions]
A -->|Exports| E[BingCountryOptions]
A -->|Exports| F[BingLanguageOptions]
A -->|Exports| G[DeepLSourceLangOptions]
A -->|Exports| H[DeepLTargetLangOptions]
A -->|Exports| I[BaiduFanyiDomainOptions]
A -->|Exports| J[BaiduFanyiSourceLangOptions]
A -->|Exports| K[QWeatherLangOptions]
A -->|Exports| L[QWeatherTypeOptions]
A -->|Exports| M[QWeatherUserTypeOptions]
A -->|Exports| N[QWeatherTimePeriodOptions]
A -->|Exports| O[ExeSQLOptions]
A -->|Exports| P[WenCaiQueryTypeOptions]
A -->|Exports| Q[Jin10TypeOptions]
A -->|Exports| R[Jin10FlashTypeOptions]
A -->|Exports| S[Jin10CalendarTypeOptions]
A -->|Exports| T[Jin10CalendarDatashapeOptions]
A -->|Exports| U[Jin10SymbolsTypeOptions]
A -->|Exports| V[Jin10SymbolsDatatypeOptions]
A -->|Exports| W[TuShareSrcOptions]
A -->|Exports| X[CrawlerResultOptions]
B -->|Used by| Y[Language Picker Components]
C -->|Used by| Y
D -->|Used by| Z[Country Selector Components]
E -->|Used by| Z
F -->|Used by| Y
G -->|Used by| AA[DeepL API Integration]
H -->|Used by| AA
I -->|Used by| AB[Baidu Translate Integration]
J -->|Used by| AB
K -->|Used by| AC[QWeather API Integration]
L -->|Used by| AC
M -->|Used by| AC
N -->|Used by| AC
O -->|Used by| AD[SQL Execution Module]
P -->|Used by| AE[WenCai Query Module]
Q -->|Used by| AF[Jin10 Data Module]
R -->|Used by| AF
S -->|Used by| AF
T -->|Used by| AF
U -->|Used by| AF
V -->|Used by| AF
W -->|Used by| AG[TuShare Data Module]
X -->|Used by| AH[Web Crawler Module]
Summary
Purpose: Provide standardized option lists for languages, countries, domains, and service-specific categories.
Format: Mostly arrays of objects with
{ label, value }or arrays of strings.Usage: Used in UI components, API integrations, and data modules for consistent user selection and parameter mapping.
No functions or classes: Purely configuration data.
Key benefit: Centralized management of options reduces duplication and errors in the app’s internationalization and API interaction layers.
If you have any questions about specific options or need integration examples, feel free to ask!