factor out the write-localized-site function