(self, path_to_pofile, resource_slug, resource_name, update_resource)
Upload source language file

        :param path_to_pofile: path to pofile
        :param resource_slug: resource slug
        :param resource_name: resource name, mostly same as resource slug itself
        :param update_resource: update resource
Upload source language file
Upload source language file
def upload_resource(self, path_to_pofile, resource_slug, resource_name, update_resource):
        """
        Upload source language file

        :param path_to_pofile: path to pofile
        :param resource_slug: resource slug
        :param resource_name: resource name, mostly same as resource slug itself
        :param update_resource: update resource
        """
        content = open(path_to_pofile, 'r', encoding="utf-8").read()
        if resource_name is None:
            __, filename = os.path.split(path_to_pofile)
            resource_name = filename
        headers = {'content-type': 'application/json'}
        data = {
            'name': resource_name, 'slug': resource_slug, 'content': content,
            'i18n_type': 'PO'
        }
        if update_resource:
            url = "https://www.transifex.com/api/2/project/{}/resource/{}/content".format(
                self.project, resource_slug)
            return requests.put(
                url, data=json.dumps(data), auth=self._auth, headers=headers,
            )
        else:
            url = "https://www.transifex.com/api/2/project/{}/resources".format(self.project)
            return requests.post(
                url, data=json.dumps(data), auth=self._auth, headers=headers,
            )
def upload_resource ( self , path_to_pofile , resource_slug , resource_name , update_resource ) : content = open ( path_to_pofile , 'r' , encoding = "utf-8" ) . read ( ) if resource_name is None : __ , filename = os . path . split ( path_to_pofile ) resource_name = filename headers = { 'content-type' : 'application/json' } data = { 'name' : resource_name , 'slug' : resource_slug , 'content' : content , 'i18n_type' : 'PO' } if update_resource : url = "https://www.transifex.com/api/2/project/{}/resource/{}/content" . format ( self . project , resource_slug ) return requests . put ( url , data = json . dumps ( data ) , auth = self . _auth , headers = headers , ) else : url = "https://www.transifex.com/api/2/project/{}/resources" . format ( self . project ) return requests . post ( url , data = json . dumps ( data ) , auth = self . _auth , headers = headers , )