use its __file__ field as an argument for the call to the function upath, substitute the result for settingsfile. call the function os.path.dirname with an argument settingsfile, join the result an string 'locale' into a file path,
localedir = os . path . join ( os . path . dirname ( settingsfile ) , 'locale' )