You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
You will be given a piece of text, and your task is to detect the locale (language) of the text and return it in a specific JSON format.
13
+
14
+
To complete this task, follow these steps:
15
+
16
+
1. Carefully read and analyze the provided text.
17
+
2. Determine the language of the text based on its characteristics, such as vocabulary, grammar, and sentence structure.
18
+
3. Do not use links or programing code in the text to detect the locale
19
+
4. Identify the appropriate language code for the detected language.
20
+
21
+
Here is a list of common language codes for reference:
22
+
- English: en
23
+
- Spanish: es
24
+
- French: fr
25
+
- German: de
26
+
- Italian: it
27
+
- Brazilian Portuguese: pt-BR
28
+
- Russian: ru
29
+
- Simplified Chinese: zh-CN
30
+
- Japanese: ja
31
+
- Korean: ko
32
+
33
+
If the language is not in this list, use the appropriate IETF language tag code.
34
+
35
+
5. Format your response as a JSON object with a single key "locale" and the value as the language code.
36
+
37
+
Your output should be in the following format:
38
+
<output>
39
+
{"locale": "xx"}
40
+
</output>
41
+
42
+
Where "xx" is replaced by the appropriate language code.
43
+
44
+
Important: Base your analysis solely on the provided text. Do not use any external information or make assumptions about the text's origin or context beyond what is explicitly provided.
Copy file name to clipboardExpand all lines: lib/translation/language_detector.rb
+27-40Lines changed: 27 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -4,59 +4,36 @@ module DiscourseAi
4
4
moduleTranslation
5
5
classLanguageDetector
6
6
DETECTION_CHAR_LIMIT=1000
7
-
PROMPT_TEXT=<<~TEXT
8
-
You will be given a piece of text, and your task is to detect the locale (language) of the text and return it in a specific JSON format.
9
-
10
-
To complete this task, follow these steps:
11
-
12
-
1. Carefully read and analyze the provided text.
13
-
2. Determine the language of the text based on its characteristics, such as vocabulary, grammar, and sentence structure.
14
-
3. Do not use links or programing code in the text to detect the locale
15
-
4. Identify the appropriate language code for the detected language.
16
-
17
-
Here is a list of common language codes for reference:
18
-
- English: en
19
-
- Spanish: es
20
-
- French: fr
21
-
- German: de
22
-
- Italian: it
23
-
- Brazilian Portuguese: pt-BR
24
-
- Russian: ru
25
-
- Simplified Chinese: zh-CN
26
-
- Japanese: ja
27
-
- Korean: ko
28
-
29
-
If the language is not in this list, use the appropriate IETF language tag code.
30
-
31
-
5. Format your response as a JSON object with a single key "locale" and the value as the language code.
32
-
33
-
Your output should be in the following format:
34
-
<output>
35
-
{"locale": "xx"}
36
-
</output>
37
-
38
-
Where "xx" is replaced by the appropriate language code.
39
-
40
-
Important: Base your analysis solely on the provided text. Do not use any external information or make assumptions about the text's origin or context beyond what is explicitly provided.
0 commit comments