Language option

main
Bob Mottram 2019-11-11 17:49:08 +00:00
parent e8fdf37dd3
commit ffea5b704e
3 changed files with 21 additions and 8 deletions

View File

@ -4383,8 +4383,8 @@ def loadTokens(baseDir: str,tokensDict: {},tokensLookup: {}) -> None:
tokensDict[nickname]=token tokensDict[nickname]=token
tokensLookup[token]=nickname tokensLookup[token]=nickname
def runDaemon(projectVersion, \ def runDaemon(language: str,projectVersion: str, \
instanceId,clientToServer: bool, \ instanceId: str,clientToServer: bool, \
baseDir: str,domain: str, \ baseDir: str,domain: str, \
port=80,proxyPort=80,httpPrefix='https', \ port=80,proxyPort=80,httpPrefix='https', \
fedList=[],maxMentions=10, \ fedList=[],maxMentions=10, \
@ -4414,9 +4414,14 @@ def runDaemon(projectVersion, \
if not os.path.isdir(baseDir+'/translations'): if not os.path.isdir(baseDir+'/translations'):
print('ERROR: translations directory not found') print('ERROR: translations directory not found')
return return
if not language:
systemLanguage=locale.getdefaultlocale()[0] systemLanguage=locale.getdefaultlocale()[0]
else:
systemLanguage=language
if '_' in systemLanguage: if '_' in systemLanguage:
systemLanguage=systemLanguage.split('_')[0] systemLanguage=systemLanguage.split('_')[0]
while '/' in systemLanguage:
systemLanguage=systemLanguage.split('/')[1]
if '.' in systemLanguage: if '.' in systemLanguage:
systemLanguage=systemLanguage.split('.')[0] systemLanguage=systemLanguage.split('.')[0]
translationsFile=baseDir+'/translations/'+systemLanguage+'.json' translationsFile=baseDir+'/translations/'+systemLanguage+'.json'

View File

@ -108,6 +108,9 @@ parser.add_argument('--proxy', dest='proxyPort', type=int,default=None, \
parser.add_argument('--path', dest='baseDir', \ parser.add_argument('--path', dest='baseDir', \
type=str,default=os.getcwd(), \ type=str,default=os.getcwd(), \
help='Directory in which to store posts') 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', \ parser.add_argument('-a','--addaccount', dest='addaccount', \
type=str,default=None, \ type=str,default=None, \
help='Adds a new account') help='Adds a new account')
@ -356,6 +359,11 @@ if args.domain:
domain=args.domain domain=args.domain
setConfigParam(baseDir,'domain',domain) setConfigParam(baseDir,'domain',domain)
if not args.language:
languageCode=getConfigParam(baseDir,'language')
if languageCode:
args.language=languageCode
# maximum number of new registrations # maximum number of new registrations
if not args.maxRegistrations: if not args.maxRegistrations:
maxRegistrations=getConfigParam(baseDir,'maxRegistrations') maxRegistrations=getConfigParam(baseDir,'maxRegistrations')
@ -1442,7 +1450,7 @@ if args.testdata:
if args.maxMentions<4: if args.maxMentions<4:
args.maxMentions=4 args.maxMentions=4
runDaemon(__version__, \ runDaemon(args.language,__version__, \
instanceId,args.client,baseDir, \ instanceId,args.client,baseDir, \
domain,port,proxyPort,httpPrefix, \ domain,port,proxyPort,httpPrefix, \
federationList,args.maxMentions, \ federationList,args.maxMentions, \

View File

@ -220,7 +220,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
testServerAliceRunning = True testServerAliceRunning = True
maxMentions=10 maxMentions=10
print('Server running: Alice') 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, \ httpPrefix,federationList,maxMentions,False, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies, \ useTor,maxReplies, \
@ -274,7 +274,7 @@ def createServerBob(path: str,domain: str,port: int,federationList: [], \
testServerBobRunning = True testServerBobRunning = True
maxMentions=10 maxMentions=10
print('Server running: Bob') 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, \ httpPrefix,federationList,maxMentions,False, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies, \ useTor,maxReplies, \
@ -308,7 +308,7 @@ def createServerEve(path: str,domain: str,port: int,federationList: [], \
testServerEveRunning = True testServerEveRunning = True
maxMentions=10 maxMentions=10
print('Server running: Eve') 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, \ httpPrefix,federationList,maxMentions,False, \
noreply,nolike,nopics,noannounce,cw,ocapAlways, \ noreply,nolike,nopics,noannounce,cw,ocapAlways, \
useTor,maxReplies,allowDeletion,True,True,False,sendThreads) useTor,maxReplies,allowDeletion,True,True,False,sendThreads)