diff --git a/daemon.py b/daemon.py index 28cf6a29..8d693e4a 100644 --- a/daemon.py +++ b/daemon.py @@ -4383,8 +4383,8 @@ def loadTokens(baseDir: str,tokensDict: {},tokensLookup: {}) -> None: tokensDict[nickname]=token tokensLookup[token]=nickname -def runDaemon(projectVersion, \ - instanceId,clientToServer: bool, \ +def runDaemon(language: str,projectVersion: str, \ + instanceId: str,clientToServer: bool, \ baseDir: str,domain: str, \ port=80,proxyPort=80,httpPrefix='https', \ fedList=[],maxMentions=10, \ @@ -4414,9 +4414,14 @@ def runDaemon(projectVersion, \ if not os.path.isdir(baseDir+'/translations'): print('ERROR: translations directory not found') return - systemLanguage=locale.getdefaultlocale()[0] + if not language: + systemLanguage=locale.getdefaultlocale()[0] + else: + systemLanguage=language if '_' in systemLanguage: systemLanguage=systemLanguage.split('_')[0] + while '/' in systemLanguage: + systemLanguage=systemLanguage.split('/')[1] if '.' in systemLanguage: systemLanguage=systemLanguage.split('.')[0] translationsFile=baseDir+'/translations/'+systemLanguage+'.json' diff --git a/epicyon.py b/epicyon.py index b0759a02..0fde404f 100644 --- a/epicyon.py +++ b/epicyon.py @@ -108,6 +108,9 @@ parser.add_argument('--proxy', dest='proxyPort', type=int,default=None, \ parser.add_argument('--path', dest='baseDir', \ type=str,default=os.getcwd(), \ help='Directory in which to store posts') +parser.add_argument('--language', dest='baseDir', \ + type=str,default=None, \ + help='Language code, eg. en/fr/de/es') parser.add_argument('-a','--addaccount', dest='addaccount', \ type=str,default=None, \ help='Adds a new account') @@ -355,7 +358,12 @@ if not os.path.isdir(baseDir+'/cache/announce'): if args.domain: domain=args.domain setConfigParam(baseDir,'domain',domain) - + +if not args.language: + languageCode=getConfigParam(baseDir,'language') + if languageCode: + args.language=languageCode + # maximum number of new registrations if not args.maxRegistrations: maxRegistrations=getConfigParam(baseDir,'maxRegistrations') @@ -1442,7 +1450,7 @@ if args.testdata: if args.maxMentions<4: args.maxMentions=4 -runDaemon(__version__, \ +runDaemon(args.language,__version__, \ instanceId,args.client,baseDir, \ domain,port,proxyPort,httpPrefix, \ federationList,args.maxMentions, \ diff --git a/tests.py b/tests.py index 72917a0f..32ac7fdc 100644 --- a/tests.py +++ b/tests.py @@ -220,7 +220,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \ testServerAliceRunning = True maxMentions=10 print('Server running: Alice') - runDaemon(__version__,"instanceId",False,path,domain,port,port, \ + runDaemon('en',__version__,"instanceId",False,path,domain,port,port, \ httpPrefix,federationList,maxMentions,False, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \ useTor,maxReplies, \ @@ -274,7 +274,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \ testServerBobRunning = True maxMentions=10 print('Server running: Bob') - runDaemon(__version__,"instanceId",False,path,domain,port,port, \ + runDaemon('en',__version__,"instanceId",False,path,domain,port,port, \ httpPrefix,federationList,maxMentions,False, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \ useTor,maxReplies, \ @@ -308,7 +308,7 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \ testServerEveRunning = True maxMentions=10 print('Server running: Eve') - runDaemon(__version__,"instanceId",False,path,domain,port,port, \ + runDaemon('en',__version__,"instanceId",False,path,domain,port,port, \ httpPrefix,federationList,maxMentions,False, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \ useTor,maxReplies,allowDeletion,True,True,False,sendThreads)