Created
September 12, 2024 08:29
-
-
Save ujnak/4cbdab3acfbd262c7a0cca4e7a39c3de to your computer and use it in GitHub Desktop.
ランタイム・メッセージの翻訳を切り替える
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Oracle APEX 24.1 でサポートされているランタイム言語 */ | |
const SUPPORTED_LANGUAGES = "ar,pt-br,hr,cs,da,nl,fi,fr,fr-ca,de,el,he,hu,is,it,ja,ko,no,pl,pt,ro,ru,sr-cyrl,sr-latn,zh-cn,sk,sl,es,sv,th,zh-tw,tr,uk,vi".split(','); | |
var taskId; | |
/* | |
* ページ・アイテムP1_LANGに切り替える言語を設定する。P1_LANGには、値の変更でページを送信する | |
* 動的アクションが設定されている。結果として切り替えた言語でAPEX_UTIL.SET_PREFENCEが呼び出され、 | |
* FSP_LANGUAGE_PREFERENCEが変更される。 | |
* | |
* P1_AUTO_SUBMITにYが設定されていると、言語の自動切り替えを継続する。 | |
*/ | |
function autoChange() { | |
let currentIndex = SUPPORTED_LANGUAGES.findIndex(lang => lang === apex.item("P1_LANG").getValue()); | |
let nextIndex = currentIndex === (SUPPORTED_LANGUAGES.length - 1) ? 0 : currentIndex + 1; | |
apex.item("P1_LANG").setValue(SUPPORTED_LANGUAGES[nextIndex]); | |
apex.item("P1_AUTO_SUBMIT").setValue("Y"); | |
} | |
/* | |
* 言語の自動切り替えを開始する。 | |
* ボタンSTART_LOOPのクリック時に呼び出される。 | |
*/ | |
function startLoop() { | |
if ( !taskId ) { | |
let interval = apex.item("P1_INTERVAL").getValue() * 1000; | |
taskId = setInterval(autoChange, interval); | |
document.getElementById("START_LOOP").disabled = true; | |
document.getElementById("STOP_LOOP").disabled = false; | |
console.log('Start Language selection changed task ', taskId); | |
} | |
} | |
/* | |
* 言語の自動切り替えを停止する。 | |
* ボタンSTOP_LOOPのクリック時に呼び出される。 | |
*/ | |
function stopLoop() { | |
if (taskId) { | |
clearInterval(taskId); | |
document.getElementById("START_LOOP").disabled = false; | |
document.getElementById("STOP_LOOP").disabled = true; | |
console.log('Stop Language selection changed task ', taskId); | |
taskId = null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment