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
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
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'

View File

@ -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')
@ -356,6 +359,11 @@ 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, \

View File

@ -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)