-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added localization and fixed registry description for hospitality
- Loading branch information
Showing
8 changed files
with
107 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"FULFILLMENT_STATUS_CODES":{ | ||
"order-picked-up":{ | ||
"message": "Your order has been picked up" | ||
}, | ||
"order-on-the-way": { | ||
"message": "Your order is on the way" | ||
}, | ||
"order-delivered":{ | ||
"message": "Your order has been delivered" | ||
}, | ||
"ticket-issued":{ | ||
"message": "Your ticket has been issued" | ||
}, | ||
"ticket-validated":{ | ||
"message": "Your ticket has been validated" | ||
}, | ||
"charging-started": { | ||
"message": "Your charging has started" | ||
}, | ||
"charging-stopped":{ | ||
"message": "Your charging has stopped" | ||
}, | ||
"charger-not-working":{ | ||
"message": "Hi, it looks likes your charger is not working. DO you want to find other chargin stations?" | ||
}, | ||
"charging-completed":{ | ||
"message": "Hi, your chargin is complete!" | ||
}, | ||
"checked-in": { | ||
"message": "You have succesfully checked-in to your stay!" | ||
}, | ||
"checked-out":{ | ||
"message": "You have succesfully checked-out from your stay!" | ||
} | ||
}, | ||
"ALL_MESSAGES": { | ||
"session_cleared": "Session cleared! You can start a new session now.", | ||
"session_and_profile_cleared": "Session & profile cleared! You can start a new session now.", | ||
"route_selected" : "Your route has been actived. Here is the link to navigate : ${url}. What do you want to do next?", | ||
"request_in_progress": "_Please wait while we process your request through open networks..._", | ||
"request_processed": "_Your request is processed, generating a response..._", | ||
"request_failed": "Request could not be processed. Do you want to try again?", | ||
"request_to_beckn_failed": "Could not process this request. Can you please try something else?", | ||
"incident_on_road" : "${message}. Please share your current location and I'll try to find some alternate routes?", | ||
"formatting_failed": "Failed to process the instruction", | ||
"api_call_failed": "Failed to call the API", | ||
"failed_to_process_instruction" : "Failed to process the instruction", | ||
"missing_source": "Can you please specify the source location?", | ||
"missing_destination": "Can you please specify the destination location?", | ||
"route_list_description": "These are the various routes that you can take. Which one would you like to select?" | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { describe, it} from 'mocha' | ||
import * as chai from 'chai' | ||
import get_text_by_key from '../../utils/language.js' | ||
const expect = chai.expect | ||
|
||
describe('test cases for language utils', ()=>{ | ||
it('Should return valid messge from language key', ()=>{ | ||
const message = get_text_by_key('session_cleared') | ||
expect(message).to.be.a('string'); | ||
}) | ||
|
||
it('Should return valid messge from language key using variable', ()=>{ | ||
let key = 'KEY_TO_MATCH' | ||
const message = get_text_by_key('route_selected', {url:key}) | ||
expect(message).to.be.a('string'); | ||
expect(message).to.contain(key); | ||
}) | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { readFileSync } from 'fs'; | ||
const language = JSON.parse(readFileSync('./config/language.json')) | ||
|
||
|
||
function get_text_by_key(key, variables = {}, category='ALL_MESSAGES'){ | ||
let text = language[category][key] || null; | ||
if (text) { | ||
text = text.replace(/\$\{(\w+)\}/g, (match, variableName) => { | ||
return variables.hasOwnProperty(variableName) ? variables[variableName] : match; | ||
}); | ||
} | ||
return text; | ||
} | ||
|
||
export default get_text_by_key; |